| Trees | Indices | Help |
|---|
|
|
1 from commands import * 2 from twisted.internet.protocol import Factory 3 from twisted.protocols.amp import AMP 4 from objects import Objects 5 from constants import UNIT_STARTING_OPACITY 6 import math 12 13 @StartGame.responder15 ''' 16 The client stub that gets called when the server starts the game 17 ''' 18 client = Objects.get_client() 19 client._init_players() 20 client.start_game() 21 return {}22 23 @AddPlayer.responder25 # print "server add player" 26 client = Objects.get_client() 27 client.playerList.append(pid) 28 return {}29 30 @UpdateHealth.responder32 # print "update_health", pid, uid, h 33 client = Objects.get_client() 34 player = client.players[pid] 35 if uid not in player.underConstruction.keys(): 36 unit = client.build_unit(tid,player,vid=vid,uid=uid) 37 else: 38 unit = player.underConstruction[uid] 39 unit.health = h 40 client._complete_build(unit, player, uid) 41 return {}42 43 @UpdateLocation.responder45 client = Objects.get_client() 46 p = client.players[pid] 47 curVertex = client.map.vertices[str(vid)] 48 client.update_location(p.units[uid], curVertex.position, curVertex) 49 return {}50 51 @BuildUnit.responder 53 # print "building unit", pid, tid, vid, uid 54 client = Objects.get_client() 55 player = client.players[pid] 56 if uid not in player.underConstruction.keys(): 57 client.build_unit(tid, player, vid=vid, uid=uid) 58 return {} 59 60 @MoveTroop.responder62 # print "server move unit", pid, vid, uid, path 63 client = Objects.get_client() 64 path = client.move_unit(client.players[pid].units[uid], path) 65 return {}66 67 @RemoveUnit.responder69 # print "remove unit", pid, uid 70 client = Objects.get_client() 71 unit = client.players[pid].units[uid] 72 unit.destroy_action() 73 return {}74 75 @Attack.responder77 # print "server_on_attack", tpid,tuid,val 78 client = Objects.get_client() 79 p = client.players[tpid] 80 if tuid in p.units.keys(): 81 p.units[tuid].client_on_attack(val) 82 return {}83 84 85 @AttackAnimation.responder87 #if no path, stop attacking 88 # print "server_animate_attack",pid,uid, tpid,tuid,path 89 client = Objects.get_client() 90 91 if (uid in client.players[pid].units.keys()): 92 attacker = client.players[pid].units[uid] 93 if tpid == -1 or tuid == -1: 94 attacker.end_attack(True) 95 elif path: 96 target = client.players[tpid].units[tuid] 97 attacker.attackingPath = path 98 if not attacker.is_attacking: 99 attacker.client_attack(target,client.map) 100 return {}101104 protocol = ServerNote105 106 107 # send: 108 # user attack 109 # user research 110 # user move 111 # user construction 112 # user unit special ability 113 # join request 114 115 # receive, do and send 116 # location update in move 117 # end of move 118 # attack progress 119 # destruction of unit 120 # construction progress 121 # construction completion 122 # research progress 123 # research completion 124
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Tue Mar 12 13:57:09 2013 | http://epydoc.sourceforge.net |