|
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 Rules |
|
23
|
|
|
import ShipUtils |
|
24
|
|
|
import Utils |
|
25
|
|
|
|
|
26
|
|
|
import Const |
|
27
|
|
|
from ige import log |
|
28
|
|
|
from IPlayer import IPlayer |
|
29
|
|
|
from ige.IObject import public |
|
30
|
|
|
from ige.IDataHolder import IDataHolder |
|
31
|
|
|
|
|
32
|
|
|
class IAIMutantPlayer(IPlayer): |
|
33
|
|
|
|
|
34
|
|
|
typeID = Const.T_AIMUTPLAYER |
|
35
|
|
|
forums = {"INBOX": 56, "OUTBOX": 56, "EVENTS": 0} |
|
36
|
|
|
|
|
37
|
|
|
def init(self, obj): |
|
38
|
|
|
IPlayer.init(self, obj) |
|
39
|
|
|
# |
|
40
|
|
|
obj.name = u'Mutant' |
|
41
|
|
|
obj.race = "m" |
|
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'Mutant faction %d' % counter |
|
49
|
|
|
obj.login = '*AIP*mutant%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_mutant') |
|
56
|
|
|
break |
|
57
|
|
|
# grant techs and so on |
|
58
|
|
|
self.cmd(obj).update(tran, obj) |
|
59
|
|
|
|
|
60
|
|
|
@staticmethod |
|
61
|
|
|
def setStartingPlanet(tran, planet): |
|
62
|
|
|
planet.plSlots = max(planet.plSlots, 9) |
|
63
|
|
|
planet.plMaxSlots = max(planet.plMaxSlots, 9) |
|
64
|
|
|
planet.plDiameter = max(planet.plDiameter, 9000) |
|
65
|
|
|
planet.slots.append(Utils.newStructure(tran, Rules.Tech.MUTANTBASE, planet.owner, Const.STRUCT_STATUS_ON, Rules.structNewPlayerHpRatio)) |
|
66
|
|
|
planet.storPop = 3000 |
|
67
|
|
|
|
|
68
|
|
|
@staticmethod |
|
69
|
|
|
def setStartingTechnologies(obj): |
|
70
|
|
|
obj.techLevel = 3 |
|
71
|
|
|
# grant technologies |
|
72
|
|
|
obj.techs[Rules.Tech.EMCANNON] = Rules.techMaxImprovement |
|
73
|
|
|
obj.techs[Rules.Tech.SSROCKET] = Rules.techMaxImprovement |
|
74
|
|
|
obj.techs[Rules.Tech.TORPEDO] = Rules.techMaxImprovement |
|
75
|
|
|
obj.techs[Rules.Tech.STLENG1] = Rules.techMaxImprovement |
|
76
|
|
|
obj.techs[Rules.Tech.FTLENG1] = 3 |
|
77
|
|
|
obj.techs[Rules.Tech.SMALLHULL1] = 3 |
|
78
|
|
|
obj.techs[Rules.Tech.SCOCKPIT1] = 3 |
|
79
|
|
|
obj.techs[Rules.Tech.SCANNERMOD1] = 3 |
|
80
|
|
|
obj.techs[Rules.Tech.CONBOMB1] = 3 |
|
81
|
|
|
obj.techs[Rules.Tech.MUTANTBASE] = 3 |
|
82
|
|
|
obj.techs[Rules.Tech.MUTANTBASE2] = 3 |
|
83
|
|
|
obj.techs[Rules.Tech.MUTANTBASE3] = 3 |
|
84
|
|
|
obj.techs[Rules.Tech.MUTANTBASE4] = 3 |
|
85
|
|
|
obj.techs[Rules.Tech.MUTANTPP1] = 3 |
|
86
|
|
|
obj.techs[Rules.Tech.MUTANTPP2] = 3 |
|
87
|
|
|
obj.techs[Rules.Tech.MUTANTFACT1] = 3 |
|
88
|
|
|
obj.techs[Rules.Tech.MUTANTFACT2] = 3 |
|
89
|
|
|
obj.techs[Rules.Tech.MUTANTMINES] = 3 |
|
90
|
|
|
|
|
91
|
|
|
@staticmethod |
|
92
|
|
|
def setStartingShipDesigns(obj): |
|
93
|
|
|
obj.shipDesigns[1] = ShipUtils.makeShipMinSpec(obj, 'Swarmer', Rules.Tech.SMALLHULL1, |
|
94
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.EMCANNON:2, Rules.Tech.STLENG1:1, Rules.Tech.FTLENG1:2}, []) |
|
95
|
|
|
obj.shipDesigns[2] = ShipUtils.makeShipMinSpec(obj, 'Seeder', Rules.Tech.MEDIUMHULL2, |
|
96
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.MUTANTPOD:1, Rules.Tech.FTLENG1:4}, []) |
|
97
|
|
|
obj.shipDesigns[3] = ShipUtils.makeShipMinSpec(obj, 'Seeker', Rules.Tech.SMALLHULL1, |
|
98
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.SCANNERMOD1:1, Rules.Tech.FTLENG1:2}, []) |
|
99
|
|
|
obj.shipDesigns[4] = ShipUtils.makeShipMinSpec(obj, 'Sower', Rules.Tech.SMALLHULL1, |
|
100
|
|
|
{Rules.Tech.SCOCKPIT1:1, Rules.Tech.CONBOMB1:1, Rules.Tech.STLENG1:1, Rules.Tech.FTLENG1:2}, []) |
|
101
|
|
|
|
|
102
|
|
|
def processINITPhase(self, tran, obj, data): |
|
103
|
|
|
IPlayer.processINITPhase(self, tran, obj, data) |
|
104
|
|
|
obj.lastLogin = time.time() |
|
105
|
|
|
# delete itself if there are no fleets and planets |
|
106
|
|
|
# delete the account as well |
|
107
|
|
|
# unregister it from the AI system |
|
108
|
|
|
if not obj.fleets and not obj.planets: |
|
109
|
|
|
self.cmd(obj).delete(tran, obj) |
|
110
|
|
|
|
|
111
|
|
|
def update(self, tran, obj): |
|
112
|
|
|
self.setStartingTechnologies(obj) |
|
113
|
|
|
self.setStartingShipDesigns(obj) |
|
114
|
|
|
# create two basic designs [they use modules not available to the |
|
115
|
|
|
# player otherwise so it has to be done this way] |
|
116
|
|
|
# call super method |
|
117
|
|
|
IPlayer.update(self, tran, obj) |
|
118
|
|
|
|
|
119
|
|
|
@public(Const.AL_ADMIN) |
|
120
|
|
|
def processRSRCHPhase(self, tran, obj, data): |
|
121
|
|
|
# do not research anything |
|
122
|
|
|
return |
|
123
|
|
|
|
|
124
|
|
|
def processFINALPhase(self, tran, obj, data): |
|
125
|
|
|
IPlayer.processFINALPhase(self, tran, obj, data) |
|
126
|
|
|
# fix goverment power |
|
127
|
|
|
obj.govPwrCtrlRange = 10000 |
|
128
|
|
|
|
|
129
|
|
|
|