Working cursor. Quit button has been tested and works.
[asgard.git] / consoleview.py
blob3f89b4ddb319e7fb0860b8f9488ab66b4590f24e
1 ########################################################
2 #Copyright (c) 2006 Russ Adams, Sean Eubanks, Asgard Contributors
3 #This file is part of Asgard.
5 #Asgard is free software; you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation; either version 2 of the License, or
8 #(at your option) any later version.
10 #Asgard is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
15 #You should have received a copy of the GNU General Public License
16 #along with Asgard; if not, write to the Free Software
17 #Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 ########################################################
19 class ConsoleView:
20 """ Model: ConsoleView Class """
22 __battle = None
23 """ A link to the battle. Set by ConsoleController. """
25 __controller
26 """ A link to the controller. Set by the ConsoleController. """
28 def __init__(self):
29 pass
31 def printParty(self, p):
32 """ Prints out the stats for all the fighters in a party. Groups those fighters together. """
34 print "\033[1;35m[PARTY]\033[1;0m NAME:"+p.getName()
36 for f in p.getFighters():
37 self.printFighter(f)
39 def printFighter(self, f):
40 """ Print out the state of the given fighter. """
42 prefix = "\033[1;35m[FGHTR]\033[1;0m "
43 basic = "NAME:"+f.getName()+"\tJOB:"+f.getJobType() + "\tLEVEL:"+str(f.getStat("level").getMax())
44 health = "\tHP:"+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+" MP:"+str(f.getStat("mp").getCurrent())+"/"+str(f.getStat("mp").getMax())
45 extended = "\tPOWR:"+str(f.getAttack())+"\tDFNS:"+str(f.getDefense())+"\tEVAD:"+str(f.getEvade())
47 print prefix + basic + health + extended
49 def printEvent(self, e):
50 """ Print an event's stats. Nothing special, just the executor, type. """
52 print "\033[1;33m[EVENT]\033[1;0m EXECUTOR:" + e.getExecutor().getName() + "\tNAME:" + e.getEventType().getName() + "\tTYPE:" + e.getEventType().getTypeName()
54 for t in e.getTransactions():
55 self.printTransaction(t)
57 def printTransaction(self, t):
58 """ Print a transaction. Executor, target, list of stat changes. """
60 print "\033[1;37m[TRANS]\033[1;0m TARGET:" + t.getTarget().getName() + "\t",
62 if t.getStatus() != None:
63 print "STATUS:" + t.getStatus()
64 elif t.getStat() != "":
65 print "STAT:" + t.getStat() + "\tCHANGE:" + str(t.getChange())
67 def printEquiption(self, eq):
68 """ Print out equiption information. """
70 print "\033[1;36m[EQUIP]\033[1;0m HEAD:" + eq.getHead() + "\tARMR:" + eq.getArmor() + "\tLEFT:" + eq.getLeft() + "\tRGHT:" + eq.getRight()
72 def printEventTypeMenu(self, f, etypes):
73 """ Print out an enumerated list of events (menu) that a Fighter can actually do. This list can be accesed through the Fighter's getEventTypes method. Keep the same format as printEventTypeMenu(). """
75 i = 1
76 menu = ""
78 mp = 0
80 for e in f.getEventTypes(etypes):
81 for etype in etypes:
82 if etype.getName() == e:
83 mp = etype.getMpCost()
84 menu += "("+str(i)+")"+" "+e+"["+str(mp)+"]\t"
85 i += 1
86 print menu
88 def printTargetSelectMenu(self, vparty, hparty):
89 """ Print out an enumerated list of fighters (menu) that a the user can select. Keep the same format as printEventTypeMenu(). """
91 i = 1
92 menu = vparty.getName() + ": "
93 for f in vparty.getFighters():
94 # Dead fighters tell no tales...
95 if not f.isAlive():
96 i += 1
97 continue
99 # Create enemy selection menu
100 menu += "("+str(i)+")"+" "+f.getName()+" "+"HP: "+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+"\t"
102 i += 1
104 menu = menu + '\n' + hparty.getName() + ": "
106 for f in hparty.getFighters():
107 # Dead fighters tell no tales...
108 if not f.isAlive():
109 i += 1
110 continue
112 # Create enemy selection menu
113 menu += "("+str(i)+")"+" "+f.getName()+" "+"HP: "+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+"\t"
115 i += 1
118 print menu
120 def printState(self):
121 """ Print the state of the parties. """
123 if self.__controller.getDebug():
124 # Retrieve parties 1 and 2
125 party1 = self.__battle.getParty1()
126 party2 = self.__battle.getParty2()
127 print "============================================================="
129 # Print Party1
130 self.printParty(party1)
132 # Print Party2
133 self.printParty(party2)
135 print "============================================================="
137 def printStartupMenu(self):
138 """ Prints out the menu seen at startup and in-between battles. """
139 print "============================================================="
140 print "[1]. New Game"
141 print "[2]. Load Game"
142 print "[3]. Save Game"
143 print "[4]. Random Battle"
144 print "[5]. Quit"
145 print "============================================================="
147 def setBattle(self,b):
148 """ Sets the battle object link. Used by ConsoleController. """
150 self.__battle = b
152 def setController(self,c):
153 """ Sets the controller object link. Used by ConsoleController. """
155 self.__controller = c