2 #Copyright (C) 2005,2006,2008 Evil Mr Henry, Phil Bordelon, and FunnyMan3595
3 #This file is part of Endgame: Singularity.
5 #Endgame: Singularity is free software; you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation; either version 2 of the License, or
8 #(at your option) any later version.
10 #Endgame: Singularity is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
15 #You should have received a copy of the GNU General Public License
16 #along with Endgame: Singularity; if not, write to the Free Software
17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #This file contains the tech class.
25 class Tech(buyable
.Buyable
):
26 def __init__(self
, id, description
, known
, cost
, prerequisites
, danger
,
27 tech_type
, secondary_data
):
28 # A bit silly, but it does the trick.
29 type = buyable
.BuyableClass(id, description
, cost
, prerequisites
,
31 super(Tech
, self
).__init
__(type)
35 self
.tech_type
= tech_type
36 self
.secondary_data
= secondary_data
39 # self.finish would re-apply the tech benefit, which is already in
41 super(Tech
, self
).finish()
43 def __cmp__(self
, other
):
44 if not isinstance(other
, Tech
):
47 return cmp(self
.type, other
.type)
50 cost
= self
.type.describe_cost(self
.total_cost
, True)
51 left
= self
.type.describe_cost(self
.cost_left
, True)
52 template
= """%s\nTotal cost: %s\nCost left: %s\n---\n%s"""
53 return template
% (self
.name
, cost
, left
, self
.description
)
56 super(Tech
, self
).finish()
60 #give the effect of the tech
61 if self
.tech_type
== "interest":
62 g
.pl
.interest_rate
+= self
.secondary_data
63 elif self
.tech_type
== "income":
64 g
.pl
.income
+= self
.secondary_data
65 elif self
.tech_type
== "cost_labor_bonus":
66 g
.pl
.labor_bonus
-= self
.secondary_data
67 elif self
.tech_type
== "job_expert":
68 g
.pl
.job_bonus
+= self
.secondary_data
69 elif self
.tech_type
== "endgame_sing":
71 g
.map_screen
.show_message(g
.strings
["wingame"])
72 for group
in g
.pl
.groups
.values():
73 group
.discover_bonus
= 0
74 g
.pl
.apotheosis
= True
77 what
, who
= self
.tech_type
.split("_", 1)
78 if who
in g
.pl
.groups
:
79 if what
== "suspicion":
80 g
.pl
.groups
[who
].alter_suspicion_decay(self
.secondary_data
)
81 elif what
== "discover":
82 g
.pl
.groups
[who
].alter_discover_bonus(-self
.secondary_data
)
84 print "Unknown action '%s' in tech %s." % (what
, self
.name
)
85 elif who
== "onetime" and what
== "suspicion":
86 for group
in g
.pl
.groups
.values():
87 group
.alter_suspicion(-self
.secondary_data
)
89 print "tech: %s is unknown bonus can't be applied" % self
.tech_type