Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
trading Class Reference

Public Member Functions

def __init__
 
def SetPriceInstability
 
def SetMaxQuantity
 
def Execute
 

Data Fields

 last_ship
 
 quantity
 
 price_instability
 
 count
 

Detailed Description

Definition at line 72 of file trading.py.

Constructor & Destructor Documentation

def __init__ (   self)

Definition at line 73 of file trading.py.

73 
74  def __init__(self):
75  self.last_ship=0
76  self.quantity=4
self.count=0

Member Function Documentation

def Execute (   self)

Definition at line 84 of file trading.py.

References trading.count, HasUndocked.count, debug.debug, trading.getImports(), random_encounters.playerdata.last_ship, trading.last_ship, patrol_ambush.quantity, plunder.quantity, defend.quantity, patrol.quantity, escort_local.quantity, cargo_mission.quantity, trading.quantity, vsrandom.random(), vsrandom.randrange(), locale.str(), and vsrandom.uniform().

84 
85  def Execute(self):
86  self.count+=1
87  if (self.count<3):
88  return
89  self.count=0
90  quant = (vsrandom.random()*(self.quantity-1))+1
91  un = VS.getUnit (self.last_ship)
92  if (un.isNull()):
93  self.last_ship=0
94  else:
95  if (un.isSignificant()):
96  if (un.isPlayerStarship()==-1):
97  global production
98  name = un.getName()
99  faction= un.getFactionName()
100  if un.isPlanet():
101  name = un.getFullname();
102  faction="planets"
103  prad=production.get((name,faction))
104  if None==prad:
105  prad= getImports(name,faction)
106  production[(name,faction)]=prad
107  if len(prad):
108  prod=prad[vsrandom.randrange(0,len(prad))]
109  cargo=VS.getRandCargo(int(prod[3]+prod[4]),prod[0])
110  if (cargo.GetCategory()==prod[0]):
111  removeCargo=False
112  if (prod[3] or prod[4]):
113  ownedcargo=un.GetCargo(cargo.GetContent())
114  quant=ownedcargo.GetQuantity()
115  #if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):
116  # debug.debug("Mining "+str(quant)+" from "+str(prod[3])+" to "+str(prod[4]))
117  if (quant<prod[3]-prod[4] or quant==0):
118  quant=int(prod[3]+vsrandom.uniform(-1,1)*prod[4])
119  #if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):
120  # debug.debug("Will add quant "+str(quant))
121  if (quant>0):
122  cargo.SetQuantity(quant)
123  price = prod[1]+vsrandom.uniform(-1,1)*prod[2]
124  cargo.SetPrice(cargo.GetPrice()*price)
125  debug.debug("Adding "+str(quant)+" of "+cargo.GetContent()+" cargo for "+str(price))
126  un.addCargo(cargo)
127  else:
128  removeCargo=True
129  elif quant>prod[3]+prod[4]:
130  removeCargo=True
131  else:
132  removeCargo=True
133  if removeCargo:
134  ownedcargo=un.GetCargo(cargo.GetContent())
135  if (ownedcargo.GetQuantity()):
136  debug.debug("Removing one "+ownedcargo.GetContent())
137 
138  un.removeCargo(ownedcargo.GetContent(),ownedcargo.GetQuantity()/3+1,0)
139  self.last_ship+=1
140 
def SetMaxQuantity (   self,
  quant 
)
def SetPriceInstability (   self,
  inst 
)

Definition at line 78 of file trading.py.

References trading.price_instability.

78 
79  def SetPriceInstability(self, inst):
80  self.price_instability=inst

Field Documentation

count

Definition at line 77 of file trading.py.

last_ship

Definition at line 74 of file trading.py.

price_instability

Definition at line 76 of file trading.py.

quantity

Definition at line 75 of file trading.py.


The documentation for this class was generated from the following file: