Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_surplus.py
Go to the documentation of this file.
1 import quest
2 import Vector
3 import VS
4 import unit
5 import vsrandom
6 import universe
8  def __init__ (self,categories,pr,qr,ships,planets):
9  print "surplus %f %f" % (pr, qr)
10  print categories
11  universe.systemCargoDemand(categories,pr,qr,ships,planets)
12  def Execute (self):
13  self.removeQuest()
14  return 0
15 
17  def __init__ (self,categories,priceratio,quantratio,ships,planets,precondition=()):
18  print "initin"
19  self.ships=ships
20  self.planets=planets
21  self.priceratio=priceratio
22  self.quantratio=quantratio
23  self.categories=categories
24  self.precond=precondition
25  quest.quest_factory.__init__ (self,"quest_surplus")
26  def precondition(self,playernum):
27  for blah in self.precond:
28  print blah
29  if (not quest.findQuest (playernum,blah)):
30  return 0
31  print "suc"
32  return 1
33  def create (self):
34  return quest_surplus(self.categories,self.priceratio,self.quantratio,self.ships,self.planets)
35 
37  (sys,mylist)=universe.getAdjacentSystems(VS.getSystemFile(),vsrandom.randrange(1,3))
38  adj=vsrandom.uniform (-.5,.5)
39  myquest=0
40  cats = tuple(set([VS.getRandCargo(1,"").GetCategory(), VS.getRandCargo(1,"").GetCategory()]))
41  news=""
42  if (adj<0):
43  news = "SURPLUS IN %s: There are reports of surpluses of %s items in the %s system. Wise Privateers have been purchasing the surpluses in hopes of future gains elsewhere." % (sys," and ".join(cats),sys)
44  else:
45  news = "DEMAND FOR %s in %s: Citizens in the %s system have been frusterated by the expensive prices and low quantities of %s goods. Privateers are currently banding together to try to bring supply to meet the demand. But while prices are still high, some big traders could certainly capitalize on this shortage." % (" AND ".join(cats),sys,sys," and ".join(cats))
46  return (sys,quest_surplus_factory(cats,1+adj,1-adj,1,1),news)
47