The Journey of a New Computer Programmer

A longtime computer-literate who wants to learn "real" programming language(s).

Monday, March 05, 2007

Naval Duels - The Lists

I am setting up the meat-and-potatoes of the basic program data as lists.

FiringOrder = ['Submarine', 'Destroyer', 'Fighter', 'Frigate', 'Cruiser', 'Battleship', 'Aircraft Carrier']
#The 7 ship classes of Naval Duels, listed in the order in which they, as a shipclass, fire during a battle.

Fire1st_Targeting = ['Submarine', 'Aircraft Carrier', 'Battleship', 'Destroyer', 'Cruiser', 'Frigate', 'Fighter']

[similar lines/lists for Fire2nd thru Fire 7th]

#The targeting priorities of the 1st ship in the 'FiringOrder' (FiringOrder[0]), which happens to be Submarine.
#Its first targeting priority is enemy submarines.
#Its second targeting priority is enemy aircraft carriers, et cetera.

Fire1st_KillChance = ['50', '25', '35', '65', '40', '80', '0']
# Submarine

#The chance-to-kill list for the 1st ship in the FiringOrder.
#The first value in the list represents its percentage chance to kill its 1st targeting priority.
#The second value in the list represents its percentage chance to kill its 2nd targeting priority, etc.

[Similar lines for Fire2nd_KillChance thru Fire7th_KillChance]

-----------------------

The idea of the above is both to provide some idea of how my game's rules work, and how I'm using lsits here.
I'm going to set everything in the main program to refer to one or more of these lists, so if I want to change these, the basic set of data that this program uses, I need only change a few relevant lines in the module file containing these lists, and the changes will "ripple through" the entire program, rather than editing every little line in the program that refers to these, the latetr sounding like a coder's nightmare.

0 Comments:

Post a Comment

<< Home