1
|
|
|
# |
2
|
|
|
# Copyright 2001 - 2016 Ludek Smid [http://www.ospace.net/] |
3
|
|
|
# |
4
|
|
|
# This file is part of Outer Space. |
5
|
|
|
# |
6
|
|
|
# Outer Space is free software; you can redistribute it and/or modify |
7
|
|
|
# it under the terms of the GNU General Public License as published by |
8
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
9
|
|
|
# (at your option) any later version. |
10
|
|
|
# |
11
|
|
|
# Outer Space is distributed in the hope that it will be useful, |
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
# GNU General Public License for more details. |
15
|
|
|
# |
16
|
|
|
# You should have received a copy of the GNU General Public License |
17
|
|
|
# along with Outer Space; if not, write to the Free Software |
18
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19
|
|
|
# |
20
|
|
|
import time |
21
|
|
|
|
22
|
|
|
import Const |
23
|
|
|
import Rules |
24
|
|
|
import ShipUtils |
25
|
|
|
import Utils |
26
|
|
|
|
27
|
|
|
from ige import log |
28
|
|
|
from ige.IDataHolder import IDataHolder |
29
|
|
|
from ige.IObject import public |
30
|
|
|
from IPlayer import IPlayer |
31
|
|
|
|
32
|
|
|
class IAIRenegadePlayer(IPlayer): |
33
|
|
|
|
34
|
|
|
typeID = Const.T_AIRENPLAYER |
35
|
|
|
forums = {"INBOX": 56, "OUTBOX": 56, "EVENTS": 0} |
36
|
|
|
|
37
|
|
|
def init(self, obj): |
38
|
|
|
IPlayer.init(self, obj) |
39
|
|
|
# |
40
|
|
|
obj.name = u'Renegade' |
41
|
|
|
obj.race = "r" |
42
|
|
|
obj.login = '*' |
43
|
|
|
|
44
|
|
View Code Duplication |
def register(self, tran, obj, galaxyID): |
|
|
|
|
45
|
|
|
log.debug("Registering player", obj.oid) |
46
|
|
|
counter = 1 |
47
|
|
|
while 1: |
48
|
|
|
obj.name = u'Renegade faction %d' % counter |
49
|
|
|
obj.login = '*AIP*renegade%d' % counter |
50
|
|
|
if galaxyID in tran.gameMngr.accountGalaxies(obj.login): |
51
|
|
|
counter += 1 |
52
|
|
|
continue |
53
|
|
|
tran.gameMngr.registerPlayer(obj.login, obj, obj.oid) |
54
|
|
|
tran.db[Const.OID_UNIVERSE].players.append(obj.oid) |
55
|
|
|
tran.gameMngr.clientMngr.createAIAccount(obj.login, obj.name, 'ais_renegade') |
56
|
|
|
break |
57
|
|
|
# grant techs and so on |
58
|
|
|
self.cmd(obj).update(tran, obj) |
59
|
|
|
|
60
|
|
|
@public(Const.AL_ADMIN) |
61
|
|
|
def processINITPhase(self, tran, obj, data): |
62
|
|
|
IPlayer.processINITPhase(self, tran, obj, data) |
63
|
|
|
|
64
|
|
|
obj.lastLogin = time.time() |
65
|
|
|
# delete itself if there are no fleets and planets |
66
|
|
|
# delete the account as well |
67
|
|
|
# unregister it from the AI system |
68
|
|
|
if not obj.fleets and not obj.planets: |
69
|
|
|
self.cmd(obj).delete(tran, obj) |
70
|
|
|
|
71
|
|
|
def update(self, tran, obj): |
72
|
|
|
self.setStartingTechnologies(obj) |
73
|
|
|
self.setStartingShipDesigns(obj) |
74
|
|
|
IPlayer.update(self, tran, obj) |
75
|
|
|
|
76
|
|
|
@staticmethod |
77
|
|
|
def setStartingPlanet(tran, planet): |
78
|
|
|
planet.plSlots = max(planet.plSlots, 9) |
79
|
|
|
planet.plMaxSlots = max(planet.plMaxSlots, 9) |
80
|
|
|
planet.plDiameter = max(planet.plDiameter, 9000) |
81
|
|
|
planet.slots.append(Utils.newStructure(tran, Rules.Tech.RENEGADEBASE2, planet.owner, Const.STRUCT_STATUS_ON, Rules.structNewPlayerHpRatio)) |
82
|
|
|
planet.storPop = 3000 |
83
|
|
|
|
84
|
|
|
@staticmethod |
85
|
|
|
def setStartingTechnologies(obj): |
86
|
|
|
obj.techLevel = 2 |
87
|
|
|
# primitives, which Renegade won't use (it's for tech tree to be correct) |
88
|
|
|
be_one = [# primitives, which Renegade won't use (it's for tech tree usage only) |
89
|
|
|
Rules.Tech.SMALLHULL0, |
90
|
|
|
Rules.Tech.MEDIUMHULL0, |
91
|
|
|
Rules.Tech.SCOCKPIT0, |
92
|
|
|
Rules.Tech.SBRIDGE0, |
93
|
|
|
Rules.Tech.CANNON0, |
94
|
|
|
Rules.Tech.SSROCKET0, |
95
|
|
|
# rest |
96
|
|
|
Rules.Tech.SMALLHULL1, |
97
|
|
|
Rules.Tech.SCOCKPIT1, |
98
|
|
|
Rules.Tech.MEDIUMHULL2, |
99
|
|
|
Rules.Tech.SBRIDGE1, |
100
|
|
|
Rules.Tech.CANNON1, |
101
|
|
|
Rules.Tech.SSROCKET, |
102
|
|
|
Rules.Tech.STEELARM2, |
103
|
|
|
Rules.Tech.NSTLENG2, |
104
|
|
|
Rules.Tech.RENEGADETITANIUMMHULL, |
105
|
|
|
Rules.Tech.RENEGADEBASE3, |
106
|
|
|
Rules.Tech.RENEGADEBASE3MINOR, |
107
|
|
|
Rules.Tech.RENEGADECOSMODROME, |
108
|
|
|
Rules.Tech.RENEGADEBASE2, |
109
|
|
|
Rules.Tech.RENEGADEBASE2MINOR] |
110
|
|
|
be_three = [Rules.Tech.STLENG1, |
111
|
|
|
Rules.Tech.RENEGADEBASE] |
112
|
|
|
|
113
|
|
|
for tech in be_one: |
114
|
|
|
if tech in obj.techs: continue |
115
|
|
|
obj.techs[tech] = 1 |
116
|
|
|
for tech in be_three: |
117
|
|
|
if tech in obj.techs: continue |
118
|
|
|
obj.techs[tech] = 3 |
119
|
|
|
|
120
|
|
|
@staticmethod |
121
|
|
|
def setStartingShipDesigns(obj): |
122
|
|
|
obj.shipDesigns[1] = ShipUtils.makeShipMinSpec(obj, 'Fighter', Rules.Tech.SMALLHULL1, |
123
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.CANNON1:1, Rules.Tech.STLENG1:2}, []) |
124
|
|
|
obj.shipDesigns[2] = ShipUtils.makeShipMinSpec(obj, 'Corvette', Rules.Tech.SMALLHULL1, |
125
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.CANNON1:2, Rules.Tech.STLENG1:1, Rules.Tech.STEELARM2:1}, []) |
126
|
|
|
obj.shipDesigns[3] = ShipUtils.makeShipMinSpec(obj, 'Frigate', Rules.Tech.MEDIUMHULL2, |
127
|
|
|
{Rules.Tech.SBRIDGE1:1, Rules.Tech.CANNON1:2, Rules.Tech.SSROCKET:2, Rules.Tech.STLENG1:2}, []) |
128
|
|
|
obj.shipDesigns[4] = ShipUtils.makeShipMinSpec(obj, 'Destroyer', Rules.Tech.MEDIUMHULL2, |
129
|
|
|
{Rules.Tech.SBRIDGE1:1, Rules.Tech.CANNON1:4, Rules.Tech.SSROCKET:2, Rules.Tech.NSTLENG2:3}, []) |
130
|
|
|
obj.shipDesigns[5] = ShipUtils.makeShipMinSpec(obj, 'Armored Cruiser', Rules.Tech.RENEGADETITANIUMMHULL, |
131
|
|
|
{Rules.Tech.SBRIDGE1:1, Rules.Tech.CANNON1:5, Rules.Tech.SSROCKET:3, Rules.Tech.STLENG1:4}, []) |
132
|
|
|
|
133
|
|
|
|