Module player_new
[hide private]
[frames] | no frames]

Source Code for Module player_new

 1  ''' 
 2  updated version of player, to be used in multiplayer mode 
 3  ''' 
 4   
 5  from pyglet.event import EventDispatcher 
 6  from cocos.layer import Layer 
 7  from models import CPU 
 8  from constants import * 
 9   
10 -class Player(EventDispatcher, Layer):
11
12 - def __init__(self, pid, special=None):
13 super(Player, self).__init__() 14 15 self.pid = pid 16 17 self.color = PLAYER_COLORS[self.pid] 18 19 #every unit has an id 20 self.uid = 0 21 22 self.units = {} #k: uid v: unit 23 24 # the units that are currently under construction 25 self.underConstruction = {} 26 27 # number to indicate completed research 28 self.completedResearch = 1 29 30 # research we haven't completed but is avialable 31 self.availableResearch = [] 32 33 #TODO: get rid of available research in favor of adding buttons 34 self.unitActionLists = { 35 "Ping": ["Ping"], 36 "PingOfDeath": ["Attack"], 37 "DOS": ["Attack"], 38 "DNSPoison":["Attack"], 39 "NMap": ["NMap"], 40 "SQLInjection": ["Attack"], 41 "Handshake": ["Shake"], 42 "BufferOverflow": ["Attack"], 43 "APTGet": [], 44 "Installer": ["BAlgorithmFactory","BSoftwareUpdater"], 45 "Firewall": [], 46 "Sinkhole": [], 47 "Server": ["TInstaller"], 48 "Spoof": ["BSpoofedBuilding"], 49 "SpoofedBuilding": ["DSpoof"], 50 "RSA": [], 51 "Database": [], 52 "SoftwareUpdater": ["RPortScanner"], 53 "AlgorithmFactory": ["TDOS"], 54 "EncryptedTroop": ["Decrypt"], 55 "CPU": [] 56 } 57 58 self.idleCPUs = [] 59 60 self.busyCPUs = []
61
62 - def set_unit_uid(self,unit,uid=-1):
63 #should really be called set_unit_uid 64 if uid == -1: #we are the server 65 unit.uid = self.uid 66 self.uid += 1 67 else: #server sent in the UID 68 unit.uid = uid 69 if self.uid <= uid: 70 self.uid += 1 71 return unit.uid
72