#!/usr/bin/env python ############################################################################## #TW2K_Character_Wizard.py # #Purpose: A utility program that creates and stores a character for the # Twilight 2000 role playing game. #Author: Cody Jackson #Date: 9/17/08 # #Copyright 2008 Cody Jackson #This program is free software; you can redistribute it and/or modify it #under the terms of the GNU General Public License as published by the Free #Software Foundation; either version 2 of the License, or (at your option) #any later version. # #This program is distributed in the hope that it will be useful, but #WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software Foundation, #Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #----------------------------------------------------------- #Version 0.1 # Initial build ############################################################################## import wx import wx.wizard as wiz import dice_roller import TW2K_lists as lists #TODO: add exception catchers for each event! #---Page title ##This moves the page title sizer box from the class initialization and into a ##separate function def makePageTitle(wizPg, title): """Create a title for the page and a separator line.""" sizer = wx.BoxSizer(wx.VERTICAL) wizPg.SetSizer(sizer) title = wx.StaticText(wizPg, -1, title) title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5) return sizer class BaseAttribs(): """Defines character attributes. Acts as a 'global variable' list.""" def __init__(self): self.fitness = 0 self.agility = 0 self.constitution = 0 self.education = 0 self.intelligence = 0 self.strength = (self.fitness + self.constitution) / 2 self.stature = 0 self.attrib_sum = (self.constitution + self.stature + self.strength + self.fitness + self.intelligence + self.education + self.agility) #---Hit points self.HPHead = self.constitution self.HPChest = self.constitution + self.strength + self.stature ##Since all these values are the same, the displayed value during ##creation is just the first value. self.HPAbdomen = self.HPLArm = self.HPRArm = self.HPLLeg = self.HPRLeg = self.constitution + self.stature #---Physical characteristics self.weight = (40 + 4 * self.stature) self.load = 2 * (self.strength + self.constitution) self.throw = 2 * self.strength #---Non-physical characteristics self.MEB = (120 - self.attrib_sum) / 7 #Military Experience Base self.TIC = dice_roller.multiDie(self.MEB, 1) #Time in combat (MEBd6) self.coolness = 10 - ((self.TIC/10) + dice_roller.multiDie(1, 1)) #10-((TIC/10)+1d6) self.rads = dice_roller.multiDie(self.MEB, 1) #Radiation level self.age = self.calcAge(self.TIC, self.education) self.rank = self.calcRank(self.intelligence, self.education, self.TIC) #---Create wizard pages class IntroPage(wiz.WizardPageSimple): """Introduction page class.""" def __init__(self, parent, title): wiz.WizardPageSimple.__init__(self, parent) ##Debugging #self.intelligence = intelligence #---Introduction text self.txtIntro = wx.StaticText(self, -1, """This wizard will walk you through creating a character for the Twilight 2000 role-playing game.\n The wizard comprises the following steps:\n 1. Generation of the basic character attributes, including entering the character's name and gender\n 2. Picking the Ethnicity and determining the languages of the character.\n 3. Choosing a Military Occupational Specialty, the job the character was trained in.\n 4. Picking the skills the character has aquired over the years.\n 5. Selecting the equipment the character will start out with.\n 6. Saving the character to a file.\n\n Click the button below to start the character creation process.""") self.txtIntro.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.sizer = makePageTitle(self, title) self.sizer.Add(self.txtIntro) class BasicInfoPage(wiz.WizardPageSimple): """Basic Character Information class.""" def __init__(self, parent, title, attribs): wiz.WizardPageSimple.__init__(self, parent) self.next = self.prev = None self.sizer = makePageTitle(self, title) self.charAttribs = attribs #---Create widgets self.label_1 = wx.StaticText(self, -1, "Character Name") self.txtNameIn = wx.TextCtrl(self, -1, "") self.label_2 = wx.StaticText(self, -1, "Gender") self.rbGender = wx.RadioBox(self, -1, "", choices=["Male", "Female"], majorDimension=2, style=wx.RA_SPECIFY_COLS) self.btnAttribs = wx.Button(self, -1, "Generate Attributes") self.label_3 = wx.StaticText(self, -1, "ATTRIBUTES") self.label_4 = wx.StaticText(self, -1, "Stature") self.txtStatureOut = wx.TextCtrl(self, -1, "") self.label_5 = wx.StaticText(self, -1, "Agility") self.txtAgilityOut = wx.TextCtrl(self, -1, "") self.label_6 = wx.StaticText(self, -1, "Constitution") self.txtConOut = wx.TextCtrl(self, -1, "") self.label_7 = wx.StaticText(self, -1, "Intelligence") self.txtIQOut = wx.TextCtrl(self, -1, "") self.label_8 = wx.StaticText(self, -1, "Education") self.txtEducationOut = wx.TextCtrl(self, -1, "") self.label_9 = wx.StaticText(self, -1, "Strength") self.txtStrOut = wx.TextCtrl(self, -1, "") self.label_10 = wx.StaticText(self, -1, "CHARACTER STATISTICS") self.label_11 = wx.StaticText(self, -1, "Weight") self.txtWeightOut = wx.TextCtrl(self, -1, "") self.label_12 = wx.StaticText(self, -1, "Load") self.txtLoadOut = wx.TextCtrl(self, -1, "") self.label_13 = wx.StaticText(self, -1, "Throw Range") self.txtThrowOut = wx.TextCtrl(self, -1, "") self.label_14 = wx.StaticText(self, -1, "Age") self.txtAgeOut = wx.TextCtrl(self, -1, "") self.label_15 = wx.StaticText(self, -1, "Hit Points: Head") self.txtHPHeadOut = wx.TextCtrl(self, -1, "") self.label_16 = wx.StaticText(self, -1, "Hit Points: Chest") self.txtHPChestOut = wx.TextCtrl(self, -1, "") self.label_17 = wx.StaticText(self, -1, "Hit Points: Other") self.txtHPOtherOut = wx.TextCtrl(self, -1, "") self.label_18 = wx.StaticText(self, -1, "Military Experience Base") self.txtMEBOut = wx.TextCtrl(self, -1, "") self.label_19 = wx.StaticText(self, -1, "Time in Combat") self.txtTICOut = wx.TextCtrl(self, -1, "") self.label_20 = wx.StaticText(self, -1, "Coolness Under Fire") self.txtCoolOut = wx.TextCtrl(self, -1, "") self.label_21 = wx.StaticText(self, -1, "Radiation Exposure") self.txtRadsOut = wx.TextCtrl(self, -1, "") self.label_22 = wx.StaticText(self, -1, "Rank") self.txtRankOut = wx.TextCtrl(self, -1, "") #---Binding events self.Bind(wx.EVT_BUTTON, self.getAttribs, self.btnAttribs) #---Layout widgets in grid grid_sizer_1 = wx.FlexGridSizer(27, 4, 0, 0) ##Row 1 grid_sizer_1.Add(self.label_1, 0, 0, 0) grid_sizer_1.Add(self.txtNameIn, 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) ##Row 2 grid_sizer_1.Add(self.label_2, 0, 0, 0) grid_sizer_1.Add(self.rbGender, 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) ##Row 3 grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) ##Row 4 grid_sizer_1.Add(self.btnAttribs, 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) ##Row 5 grid_sizer_1.Add(self.label_3, 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) grid_sizer_1.Add(self.label_10, 0, 0, 0) grid_sizer_1.Add((20, 20), 0, 0, 0) ##Row 6 grid_sizer_1.Add(self.label_4, 0, 0, 0) grid_sizer_1.Add(self.txtStatureOut, 0, 0, 0) grid_sizer_1.Add(self.label_15, 0, 0, 0) grid_sizer_1.Add(self.txtHPHeadOut, 0, 0, 0) ##Row 7 grid_sizer_1.Add(self.label_5, 0, 0, 0) grid_sizer_1.Add(self.txtAgilityOut, 0, 0, 0) grid_sizer_1.Add(self.label_16, 0, 0, 0) grid_sizer_1.Add(self.txtHPChestOut, 0, 0, 0) ##Row 8 grid_sizer_1.Add(self.label_6, 0, 0, 0) grid_sizer_1.Add(self.txtConOut, 0, 0, 0) grid_sizer_1.Add(self.label_17, 0, 0, 0) grid_sizer_1.Add(self.txtHPOtherOut, 0, 0, 0) ##Row 9 grid_sizer_1.Add(self.label_7, 0, 0, 0) grid_sizer_1.Add(self.txtIQOut, 0, 0, 0) grid_sizer_1.Add(self.label_18, 0, 0, 0) grid_sizer_1.Add(self.txtMEBOut, 0, 0, 0) ##Row 10 grid_sizer_1.Add(self.label_8, 0, 0, 0) grid_sizer_1.Add(self.txtEducationOut, 0, 0, 0) grid_sizer_1.Add(self.label_19, 0, 0, 0) grid_sizer_1.Add(self.txtTICOut, 0, 0, 0) ##Row 11 grid_sizer_1.Add(self.label_9, 0, 0, 0) grid_sizer_1.Add(self.txtStrOut, 0, 0, 0) grid_sizer_1.Add(self.label_20, 0, 0, 0) grid_sizer_1.Add(self.txtCoolOut, 0, 0, 0) ##Row 12 grid_sizer_1.Add(self.label_11, 0, 0, 0) grid_sizer_1.Add(self.txtWeightOut, 0, 0, 0) grid_sizer_1.Add(self.label_21, 0, 0, 0) grid_sizer_1.Add(self.txtRadsOut, 0, 0, 0) ##Row 13 grid_sizer_1.Add(self.label_12, 0, 0, 0) grid_sizer_1.Add(self.txtLoadOut, 0, 0, 0) grid_sizer_1.Add(self.label_14, 0, 0, 0) grid_sizer_1.Add(self.txtAgeOut, 0, 0, 0) ##Row 14 grid_sizer_1.Add(self.label_13, 0, 0, 0) grid_sizer_1.Add(self.txtThrowOut, 0, 0, 0) grid_sizer_1.Add(self.label_22, 0, 0, 0) grid_sizer_1.Add(self.txtRankOut, 0, 0, 0) self.sizer.Add(grid_sizer_1) # TODO: refactor getAttribs() def getAttribs(self, event): # wxGlade: CharCreator. """Get attributes and print to screen.""" #---Physical attributes self.charAttribs.fitness = self.genAttribs() self.charAttribs.agility = self.genAttribs() self.txtAgilityOut.SetValue(str(self.charAttribs.agility)) self.charAttribs.constitution = self.genAttribs() self.txtConOut.SetValue(str(self.charAttribs.constitution)) self.charAttribs.education = self.genAttribs() self.txtEducationOut.SetValue(str(self.charAttribs.education)) self.charAttribs.intelligence = self.genAttribs() self.txtIQOut.SetValue(str(self.charAttribs.intelligence)) self.charAttribs.strength = ((self.charAttribs.fitness + self.charAttribs.constitution) / 2) self.txtStrOut.SetValue(str(self.charAttribs.strength)) self.charAttribs.stature = self.genAttribs() self.txtStatureOut.SetValue(str(self.charAttribs.stature)) self.attrib_sum = (self.charAttribs.constitution + self.charAttribs.stature + self.charAttribs.strength + self.charAttribs.fitness + self.charAttribs.intelligence + self.charAttribs.education + self.charAttribs.agility) #---Hit points self.charAttribs.HPHead = self.charAttribs.constitution self.txtHPHeadOut.SetValue(str(self.charAttribs.HPHead)) self.charAttribs.HPChest = self.charAttribs.constitution + self.charAttribs.strength + self.charAttribs.stature self.txtHPChestOut.SetValue(str(self.charAttribs.HPChest)) ##Since all these values are the same, the displayed value during ##creation is just the first value. self.charAttribs.HPAbdomen = self.charAttribs.HPLArm = self.charAttribs.HPRArm = self.charAttribs.HPLLeg = self.charAttribs.HPRLeg = self.charAttribs.constitution + self.charAttribs.stature self.txtHPOtherOut.SetValue(str(self.charAttribs.HPAbdomen)) #---Physical characteristics self.charAttribs.weight = (40 + 4 * self.charAttribs.stature) self.txtWeightOut.SetValue(str(self.charAttribs.weight)) self.charAttribs.load = 2 * (self.charAttribs.strength + self.charAttribs.constitution) self.txtLoadOut.SetValue(str(self.charAttribs.load)) self.charAttribs.throw = 2 * self.charAttribs.strength self.txtThrowOut.SetValue(str(self.charAttribs.throw)) #---Non-physical characteristics self.charAttribs.MEB = (120 - self.attrib_sum) / 7 #Military Experience Base self.txtMEBOut.SetValue(str(self.charAttribs.MEB)) self.charAttribs.TIC = dice_roller.multiDie(self.charAttribs.MEB, 1) #Time in combat (MEBd6) self.txtTICOut.SetValue(str(self.charAttribs.TIC)) self.charAttribs.coolness = 10 - ((self.charAttribs.TIC/10) + #10-((TIC/10)+1d6) dice_roller.multiDie(1, 1)) self.txtCoolOut.SetValue(str(self.charAttribs.coolness)) self.charAttribs.rads = dice_roller.multiDie(self.charAttribs.MEB, 1) #Radiation level self.txtRadsOut.SetValue(str(self.charAttribs.rads)) self.charAttribs.age = self.calcAge(self.charAttribs.TIC, self.charAttribs.education) self.txtAgeOut.SetValue(str(self.charAttribs.age)) self.charAttribs.rank = self.calcRank(self.charAttribs.intelligence, self.charAttribs.education, self.charAttribs.TIC) self.txtRankOut.SetValue(str(self.charAttribs.rank)) ##Debugging ## print (self.MEB, self.TIC, self.coolness, self.rads, self.age, ## self.HPHead, self.HPChest, self.HPAbdomen, self.HPLArm, self.HPRArm, ## self.HPLLeg, self.HPRLeg, self.rank) def calcRank(self, iq, ed, time): """Calculate character's rank and return the value.""" self.iq = iq self.ed = ed self.time = time #Officer or enlisted if (dice_roller.multiDie(2, 1) + 16) > (self.iq + self.ed): self.enlisted = 1 #Character is enlisted else: self.enlisted = 0 #Character is officer #Round fractions down if self.time % 10 > 5: self.t = (self.time / 10) + 1 else: self.t = self.time / 10 #"Random" modifier to rank self.mod = dice_roller.multiDie(1, 1) if 1 < self.mod < 2: self.t -= 1 elif 5 < self.mod < 6: self.t += 1 #Return rank name if self.enlisted == 1: return lists.enlisted_ranks[self.t] else: return lists.officer_ranks[self.t] def calcAge(self, time, ed): """Calculate a character's age based on time in combat and education.""" self.time = time self.ed = ed #Round fractions up if self.time % 12 < 5: self.tmp_age = (self.time/12) + self.ed + 8 else: self.tmp_age = ((self.time/12) + 1) + self.ed + 8 #Create age modifier based on time in combat if self.time < 50: self.mod = dice_roller.multiDie(1, 1) elif 50 < self.time < 60: self.mod = dice_roller.multiDie(2, 1) elif 60 < self.time < 70: self.mod = dice_roller.multiDie(3, 1) elif self.time >= 70: self.mod = dice_roller.multiDie(4, 1) self.final_age = self.tmp_age + self.mod return self.final_age def genAttribs(self): """Calculate and return values for physical attributes.""" val = dice_roller.multiDie(4, 1) - 4 return val class Ethnicity(wiz.WizardPageSimple): """Army, Ethnicity, and Languages class.""" def __init__(self, parent, title): wiz.WizardPageSimple.__init__(self, parent) self.next = self.prev = None self.sizer = makePageTitle(self, title) #---Create widgets self.instructions = wx.StaticText(self, -1, """Choose a nationality (ethnicity) from the following list. Your choice will affect the native languages available to your character at the start of the game. This list box includes both NATO and Eastern Bloc nationalities.""") self.instructions.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.ethnicityListBox = wx.ListBox(self, -1, size = (150, 150), pos = (0, 0), choices = lists.all_nationalities) self.ethnicityListBox.SetFont(wx.Font(10, #Make font bigger wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.langLabel = wx.StaticText(self, -1, "Native Languages") self.langLabel.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.txtLang = wx.TextCtrl(self, -1, size = (150, 20), value = "") #---Event Binding self.Bind(wx.EVT_LISTBOX, self.ethnicChoice, self.ethnicityListBox) #---Place widgets self.sizer.Add(self.instructions) self.sizer.Add((20, 20), 0, 0, 0) self.sizer.Add(self.ethnicityListBox) self.sizer.Add((20, 20), 0, 0, 0) self.sizer.Add(self.langLabel) self.sizer.Add(self.txtLang) #TODO:refactor ethnicChoice() def ethnicChoice(self, event): """Get nationality choice and return languages. Determines if there are any additional languages to add to the list.""" self.ethChoice = self.ethnicityListBox.GetStringSelection() self.txtLang.Clear() #Clear any previous entries ##US if self.ethChoice == "American": self.txtLang.WriteText("English") if dice_roller.randomNumGen(3) <= 10: self.txtLang.AppendText(", Spanish") elif dice_roller.randomNumGen(3) <= 2: self.txtLang.AppendText(", German") elif dice_roller.randomNumGen(3) <= 2: self.txtLang.AppendText(", Italian") elif dice_roller.randomNumGen(3) <= 1: self.txtLang.AppendText(", Polish") elif dice_roller.randomNumGen(3) <= 2: self.txtLang.AppendText(", Yiddish") ##Canadian elif self.ethChoice == "Anglo-Canadian": self.txtLang.WriteText("English") if dice_roller.randomNumGen(3) <= 30: self.txtLang.AppendText(", French") elif self.ethChoice == "French-Canadian": self.txtLang.WriteText("French") if dice_roller.randomNumGen(3) <= 30: self.txtLang.AppendText(", English") ##British elif self.ethChoice == "English": self.txtLang.WriteText("English") elif self.ethChoice == "Welsh": self.txtLang.WriteText("English") if dice_roller.randomNumGen(3) <= 20: self.txtLang.AppendText(", Welsh") elif self.ethChoice == "Scottish": self.txtLang.WriteText("English") if dice_roller.randomNumGen(3) <= 30: self.txtLang.AppendText(", Scots Gaelic") elif self.ethChoice == "Irish": self.txtLang.WriteText("English") if dice_roller.randomNumGen(3) <= 20: self.txtLang.AppendText(", Gaelic") ##Danish elif self.ethChoice == "Danish": self.txtLang.WriteText("Danish") ##Germany elif self.ethChoice == "West German" or self.ethChoice =="East German": self.txtLang.WriteText("German") ##Poland elif self.ethChoice == "Polish": self.txtLang.WriteText("Polish") ##Hungary elif self.ethChoice == "Hungarian": self.txtLang.WriteText("Hungarian") if dice_roller.randomNumGen(3) <= 3: self.txtLang.AppendText(", German") elif dice_roller.randomNumGen(3) <= 2: self.txtLang.AppendText(", Romany") ##Czechoslovakia elif self.ethChoice == "Czech": self.txtLang.WriteText("Czech") if dice_roller.randomNumGen(3) <= 10: self.txtLang.AppendText(", Slovak") elif dice_roller.randomNumGen(3) <= 3: self.txtLang.AppendText(", Hungarian") elif dice_roller.randomNumGen(3) <= 1: self.txtLang.AppendText(", Romany") elif self.ethChoice == "Slovak": self.txtLang.WriteText("Czech") if dice_roller.randomNumGen(3) <= 80: self.txtLang.AppendText(", Slovak") elif dice_roller.randomNumGen(3) <= 3: self.txtLang.AppendText(", Hungarian") elif dice_roller.randomNumGen(3) <= 1: self.txtLang.AppendText(", Romany") ##Soviet elif (self.ethChoice == "Russian" or self.ethChoice == "Ukrainian" or self.ethChoice == "Byelorussian"): self.txtLang.WriteText("Russian") else: self.txtLang.WriteText(self.ethChoice) #Other countries get their own language ##Debugging #print self.ethnicityListBox.GetSelection() #print self.ethnicityListBox.GetStringSelection() class MOS(wiz.WizardPageSimple): """Character's job class.""" def __init__(self, parent, title, attribs): wiz.WizardPageSimple.__init__(self, parent) self.next = self.prev = None self.sizer = makePageTitle(self, title) self.charAttribs = attribs #---Create widgets self.MOS_intro = wx.StaticText(self, -1, """Based on your character's attributes, you are eligible certain specialties.\n A dice roll will be made to determine if you are selected for that speciality. If you are not selected for your first choice, you may choose a second speciality. However, the next die roll will be modified, making it more difficult for you to get the second choice. If you fail at both attempts, your only choices will be from the Support Branch.\n""") self.MOS_intro.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.MOS_list = ["Aircraft Mechanic", "Vehicle Mechanic", "Electronics Specialist", "Infantryman", "Heavy Weapons", "Tank Crewman", "Cavalry Scout"] self.characterMOS = "" self.jobChoice = "" self.modRoll = 0 self.btn = wx.Button(self, -1, "Display specialities") self.btn2 = wx.Button(self, -1, "Select choice") ## self.box1_title = wx.StaticBox( self, -1, "" ) ## self.box1 = wx.StaticBoxSizer( self.box1_title, wx.VERTICAL ) ## self.grid1 = wx.GridSizer(0, 2, 0, 0) #---Binding events self.Bind(wx.EVT_BUTTON, self.eligibleMOS, self.btn) self.Bind(wx.EVT_BUTTON, self.selectMOS, self.btn2) #---Place widgets self.sizer.Add(self.MOS_intro) self.sizer.Add(self.btn) self.btn2.Hide() #self.grid1.Show(False) def eligibleMOS(self, event): """Determine which MOSes a character is eligible for. Each if statement will add to the one previous, if justified.""" if self.charAttribs.intelligence >= 12: skillList = ["Analyst", "Interrogator", "Fire Support Specialist", "Combat Medic", "Atomic Demolition Munitions Specialist", "Aircraft Pilot"] for skill in skillList: self.MOS_list.append(skill) #print self.MOS_list ##Debugging if self.charAttribs.constitution >= 12: skillList = ["Combat Engineer", "Ranger: Infantry", "Ranger: Heavy Weapons", "Special Forces: Weapons Specialist"] for skill in skillList: self.MOS_list.append(skill) #print self.MOS_list ##Debugging if self.charAttribs.constitution >= 12 and self.charAttribs.intelligence >= 12: self.MOS_list.append("Special Forces: Intelligence Specialist") #print self.MOS_list ##Debugging if self.charAttribs.strength >= 12: self.MOS_list.append("Cannon Crewman") #print self.MOS_list ##Debugging self.createMOSList(self.MOS_list) self.sizer.Add(self.MOSListBox) self.btn2.Show() self.sizer.Add(self.btn2) self.Layout() self.Fit() def createMOSList(self, list): """Generate listbox filled with eligible MOSes.""" self.MOS_list = list self.MOSListBox = wx.ListBox(self, -1, size = (250, 175), pos = (0, 0), choices = self.MOS_list, style=wx.LB_ALWAYS_SB) self.MOSListBox.SetFont(wx.Font(10, #Make font bigger wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.Bind(wx.EVT_LISTBOX, self.OnMOSChoice, self.MOSListBox) def OnMOSChoice(self, event): """Get the MOS selection.""" self.necRoll = 0 #print self.MOSListBox.GetStringSelection() self.jobChoice = self.MOSListBox.GetStringSelection() self.jobIndex = self.MOSListBox.GetSelection() #print self.jobChoice, self.necRoll if self.jobChoice in ("Aircraft Mechanic", "Vehicle Mechanic", "Electronics Specialist"): self.necRoll = 0 if self.jobChoice in ("Infantryman", "Combat Engineer"): self.necRoll = 5 if self.jobChoice in ("Heavy Weapons", "Atomic Demolition Munitions Specialist", "Combat Medic", "Cannon Crewman", "Fire Support Specialist"): self.necRoll = 6 if self.jobChoice in ("Tank Crewman", "Cavalry Scout", "Ranger: Infantry", "Ranger: Heavy Weapons"): self.necRoll = 7 if self.jobChoice in ("Aircraft Pilot", "Special Forces: Weapons Specialist", "Special Forces: Intelligence Specialist", "Analyst", "Interrogator"): self.necRoll = 8 ##Debugging #print self.necRoll #print "OnMOSChoice() index", self.jobIndex def selectMOS(self, event): """Determine if character has selected MOS.""" ##Debugging #self.count = 0 #self.modRoll = 0 #Roll modifier if MOS not received previously #print "roll modifier ", self.modRoll #print "selectMOS() index", self.jobIndex #print "initial list box count", self.MOSListBox.GetCount() if self.modRoll < 4: #Let player choose MOS until valid self.roll = dice_roller.multiDie(2, 1) - self.modRoll ##Debugging #self.roll = 1 #print "roll modifier ", self.modRoll #print "roll", self.roll #print "needed", self.necRoll #print "loop start list box count", self.MOSListBox.GetCount() if self.roll >= self.necRoll: #MOS selection is valid #if dice_roller.multiDie(2, 1) >= self.necRoll: self.characterMOS = self.MOSListBox.GetStringSelection() #print "winner", self.characterMOS ##Debugging self.dlgSelected = wx.MessageDialog(self, "You were selected for the %s MOS" % self.characterMOS, "Congratulations", wx.OK | wx.ICON_INFORMATION) self.dlgSelected.ShowModal() self.dlgSelected.Destroy() else: #print "Try again" ##Change to dialog box self.dlgNotSelected = wx.MessageDialog(self, "You weren't selected for that MOS. Please choose again.", "Not Selected", wx.OK | wx.ICON_EXCLAMATION) self.dlgNotSelected.ShowModal() self.dlgNotSelected.Destroy() self.MOSListBox.Delete(self.jobIndex) #Prevents user from reselected choice self.modRoll += 2 ##Debugging #print "end modRoll", self.modRoll, "\n" #print "loop end list box count", self.MOSListBox.GetCount() else: #Player exceeds number of rolls ##Debugging #print "Mechanic" #print "list box count", self.MOSListBox.GetCount() #for value in range(3, self.MOSListBox.GetCount()): # self.MOSListBox.Delete(value) ## self.dlgNotSelected = wx.MessageDialog(self, "You weren't selected for that MOS. Please choose again.", ## "Not Selected", wx.OK | wx.ICON_EXCLAMATION) ## self.dlgNotSelected.ShowModal() ## self.dlgNotSelected.Destroy() self.supportDialog = wx.SingleChoiceDialog(self, "You were not chosen for any of your selections. You must now choose from one of the following support services.", "Support Service Selection", lists.support_MOS, wx.CHOICEDLG_STYLE) if self.supportDialog.ShowModal() == wx.ID_OK: self.characterMOS = self.supportDialog.GetStringSelection() print self.characterMOS ##Debugging self.supportDialog.Destroy() class Skills(wiz.WizardPageSimple): """Character's skill selection.""" def __init__(self, parent, title, attribs): wiz.WizardPageSimple.__init__(self, parent) self.next = self.prev = None self.sizer = makePageTitle(self, title) self.charAttribs = attribs #---Run the wizard if __name__ == "__main__": app = wx.PySimpleApp() wizard = wiz.Wizard(None, -1, "TW2K Character Creation") attribs = BaseAttribs #---Create each page page1 = IntroPage(wizard, "Introduction") page2 = BasicInfoPage(wizard, "Basic Info", attribs) page3 = Ethnicity(wizard, "Ethnicity") page4 = MOS(wizard, "Military Occupational Specialty", attribs) page5 = IntroPage(wizard, "Ending") #---Page chain wiz.WizardPageSimple_Chain(page1, page2) wiz.WizardPageSimple_Chain(page2, page3) wiz.WizardPageSimple_Chain(page3, page4) wiz.WizardPageSimple_Chain(page4, page5) wizard.FitToPage(page1) if wizard.RunWizard(page1): print "Success"