Fighter.addStatus defect fixed. Only event types that have enough mp are displayed...
[asgard.git] / consoleview.py
blobb2bd45175542a1c5273be604c445915f67e9bf7f
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 """Viewer object for Asgard"""
22 def __init__(self):
23 pass
25 def printParty(self, p):
26 """Show party stats."""
28 print "\033[1;35m[PARTY]\033[1;0m NAME:"+p.getName()
30 for f in p.getFighters():
31 self.printFighter(f)
33 def printFighter(self, f):
34 """Show fighter stats."""
36 print "\033[1;35m[FGHTR]\033[1;0m NAME:"+f.getName()+"\tJOB:"+f.getJobType()+"\tHP:"+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+"\tPOWR:"+str(f.getAttack())+"\tDFNS:"+str(f.getDefense())+"\tEVAD:"+str(f.getEvade())
38 def printEvent(self, e):
39 """Show Event data."""
42 print "\033[1;33m[EVENT]\033[1;0m EXECUTOR:" + e.getExecutor().getName() + "\tNAME:" + e.getEventType().getName() + "\tTYPE:" + e.getEventType().getTypeName()
44 for t in e.getTransactions():
45 self.printTransaction(t)
47 def printTransaction(self, t):
49 print "\033[1;37m[TRANS]\033[1;0m TARGET:" + t.getTarget().getName() + "\t",
51 if t.getStatus() != None:
52 print "STATUS:" + t.getStatus()
53 elif t.getStat() != "":
54 print "STAT:" + t.getStat() + "\tCHANGE:" + str(t.getChange())
56 def printEquiption(self, eq):
57 """Show equiption for fighter."""
59 print "\033[1;36m[EQUIP]\033[1;0m HEAD:" + eq.getHead() + "\tARMR:" + eq.getArmor() + "\tLEFT:" + eq.getLeft() + "\tRGHT:" + eq.getRight()
61 def printEventTypeMenu(self, f, etypes):
62 """Show battle menu options for fighter."""
64 i = 1
65 menu = ""
67 mp = 0
69 for e in f.getEventTypes(etypes):
70 for etype in etypes:
71 if etype.getName() == e:
72 mp = etype.getMpCost()
73 menu += "("+str(i)+")"+" "+e+"["+str(mp)+"]\t"
74 i += 1
75 print menu
77 def printTargetSelectMenu(self, vparty, hparty):
78 """Show enemy selection options for fighter"""
80 i = 1
81 menu = vparty.getName() + ": "
82 for f in vparty.getFighters():
83 # Dead fighters tell no tales...
84 if not f.isAlive():
85 i += 1
86 continue
88 # Create enemy selection menu
89 menu += "("+str(i)+")"+" "+f.getName()+" "+"HP: "+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+"\t"
91 i += 1
93 menu = menu + '\n' + hparty.getName() + ": "
95 for f in hparty.getFighters():
96 # Dead fighters tell no tales...
97 if not f.isAlive():
98 i += 1
99 continue
101 # Create enemy selection menu
102 menu += "("+str(i)+")"+" "+f.getName()+" "+"HP: "+str(f.getStat("hp").getCurrent())+"/"+str(f.getStat("hp").getMax())+"\t"
104 i += 1
107 print menu
109 def printState(self):
110 """Show state."""
112 if self.__controller.getDebug():
113 # Retrieve parties 1 and 2
114 party1 = self.__battle.getParty1()
115 party2 = self.__battle.getParty2()
116 print "============================================================="
118 # Print Party1
119 self.printParty(party1)
121 # Print Party2
122 self.printParty(party2)
124 print "============================================================="
126 def printStartupMenu(self):
127 print "============================================================="
128 print "[1]. New Game"
129 print "[2]. Load Game"
130 print "[3]. Save Game"
131 print "[4]. Random Battle"
132 print "[5]. Quit"
133 print "============================================================="
135 def setBattle(self,b):
136 self.__battle = b
138 def setController(self,c):
139 self.__controller = c