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

Functions

def getNewInfo
 
def getNode
 
def getPreconditions
 
def getAllNewInfo
 
def getInitialInfo
 
def evaluateCondition
 
def evaluateConditions
 
def setB
 
def sampleNode
 
def sampleCon
 

Variables

int b = 1
 

Function Documentation

def fixer_lib.evaluateCondition (   condition)
Takes a string representing the condition, and returns whether it is
met or not.

Definition at line 74 of file fixer_lib.py.

References campaign_lib.checkSaveValue(), and locale.str().

74 
75 def evaluateCondition(condition):
76  """Takes a string representing the condition, and returns whether it is
77  met or not."""
78  if type(condition) != str:
79  raise TypeError("The condition is not a valid type.")
80  elif condition == str():
81  return 1
82  elif condition[0] == '#':
83  tempd = dict()
84  exec condition[1:] in tempd
85  print "Custom condition code, returning: " + str(tempd["result"])
86  return tempd["result"]
87  else:
88  con = condition.split('#')
89  print "Checking \'%s : %s\'"%(con[0],con[1])
90  print "Returning: " + str(checkSaveValue(VS.getCurrentPlayer(),con[0],int(con[1])))
91  return checkSaveValue(VS.getCurrentPlayer(),con[0],int(con[1]))
def fixer_lib.evaluateConditions (   conditions)
Takes a list of conditions, and evaluates them.

Definition at line 92 of file fixer_lib.py.

References evaluateCondition().

92 
93 def evaluateConditions(conditions):
94  """Takes a list of conditions, and evaluates them."""
95  for cond in conditions:
96  if not evaluateCondition(cond):
97  return 0
98  return 1
def fixer_lib.getAllNewInfo (   conversation,
  ref = "Root" 
)
Retrieves the suitable text and choices, as well as the sprite and
mouseover text.

Definition at line 47 of file fixer_lib.py.

References evaluateConditions(), getNode(), dospath.split(), and locale.str().

47 
48 def getAllNewInfo(conversation, ref="Root"):
49  """Retrieves the suitable text and choices, as well as the sprite and
50  mouseover text."""
51  segs = getNode(conversation, ref).split('^')[1:]
52  default = segs.pop()
53  use = False
54  for seg in segs:
55  sseg = seg.split('|')
56  if evaluateConditions(sseg[0]):
57  use = sseg
58  break
59  if not use:
60  use = default.split('|')
61  while len(use) < 5:
62  use.append(str())
63  return use[1], use[2], use[3], use[4]
def fixer_lib.getInitialInfo (   conversation)
Retrieves the initial starting objects required for the CFixer class.
This is the starting text, choices, and preconditions.  text and choices
are both strings, but the preconditions returned may be a list.

Definition at line 64 of file fixer_lib.py.

References getAllNewInfo(), getNode(), getPreconditions(), and dospath.split().

64 
65 def getInitialInfo(conversation):
66  """Retrieves the initial starting objects required for the CFixer class.
67  This is the starting text, choices, and preconditions. text and choices
68  are both strings, but the preconditions returned may be a list."""
69  name = getNode(conversation).split('^')[0].split('|')[1]
70  whenclicked = getNode(conversation).split('^')[0].split('|')[2]
71  text, choices, sprite, motext = getAllNewInfo(conversation)
72  precon = getPreconditions(conversation)
73  return text, whenclicked, sprite, motext, name, precon
def fixer_lib.getNewInfo (   conversation,
  ref = "Root" 
)
Returns two strings, the first is the text for the node, the second is
the choices.

Definition at line 26 of file fixer_lib.py.

References getAllNewInfo().

26 
27 def getNewInfo(conversation, ref="Root"):
28  """Returns two strings, the first is the text for the node, the second is
29  the choices."""
30  text, choices, sprite, motext = getAllNewInfo(conversation, ref)
31  return text, choices
def fixer_lib.getNode (   conversation,
  ref = "Root" 
)
Gets the node in the conversation corresponding to \'ref\'

Definition at line 32 of file fixer_lib.py.

References dospath.split().

32 
33 def getNode(conversation, ref="Root"):
34  """Gets the node in the conversation corresponding to \'ref\'"""
35  for node in conversation:
36  if node.split('^')[0].split('|')[0] == ref:
37  return node
38  raise RuntimeError("Node with reference \'%s\' not found in conversation."%ref)
def fixer_lib.getPreconditions (   conversation)
Gets the preconditions for the conversation.

Definition at line 39 of file fixer_lib.py.

References getNode(), dospath.split(), and locale.str().

39 
40 def getPreconditions(conversation):
41  """Gets the preconditions for the conversation."""
42  pre = getNode(conversation).split('^')[0].split('|')
43  if len(pre) < 4:
44  return str()
45  else:
46  return pre[3]
def fixer_lib.sampleCon ( )

Definition at line 106 of file fixer_lib.py.

107 def sampleCon():
108  return ["Node2^#b==1|\"Aar! This ale is mighty fine. You there, walk the plank!\"|choices^#b==2|\"Land Ahoy!\"|choices","Root|#a==2^#b==1|\"Aar! This RootBeer is mighty fine. You are scummvm.\"|choices|sprite|mouseover^#b==2|\"Land AhoyRoot!\"|choices2|sprite2|mouseover2"]
109 
110 
111 
112 
113 
114 #Root Node:
115 # + Conversation preconditions
116 # + Text contains strin reference to possible starting nodes
117 # +
118 #Root|pirate.spr|"A Pirate"^preconditions^n1|n2|n3^
119 #
120 #
121 #Node:
122 # + Primary preconditions (is this node possible)
123 # + Secondary preconditions (what specific text makes sense...ie, no sense talking about an event that hasn't happened yet)
124 # + Each set of secondary precons has a related text node and choices set (and maybe sprite?)
125 #
126 #n1|pirate_angry.spr|"An Angry Pirate"^ ......... the segments would only occur for the topmost nodes, where it is possible to alter the initial appearance still.
127 #
128 #you would normally have:
129 #
130 #The node structure:
131 #
132 #n2|prim_preconditions^sec_precons|"Aar! This ale is mighty fine. You there, walk the plank!"|choices|sprite|mouseover^sec_precons|"Land Ahoy!"|choices|sprite|mouseover
133 #
134 #Segments are seperated by the '^' character, elements (within each segment) by the '|'
135 #The first segment has two elements, the first is the reference, the second the precondition for node activation. This precondition, if it exists, will be ignored for references not equal to 'Root'.
136 #Each additional segment (minimum of 1) contains a possible value for this node. Each (in the order the are written) have their preconditions evaluated. The first to get the 'all clear' becomes this node, the text and choices are evaluated (and if the reference of the node is 'Root', then so are the sprite and mouseover values) and used.
137 #
138 #
139 #class Conversation:
140 # """Takes a string of the content making up a fixer converstion, and
141 # provides various methods to access and display the interaction."""
142 #
143 # def __init__(self, content):
144 #do error check for type 'content' etc
145 # self.content = content.split()
146 # self.content.sort()
147 # pass
148 #
149 # def getNode(ref="Root"):
150 # """Gets the conversation node with a reference of \'ref\'."""
151 #do error check for type etc
152 #
153 # def getNextNode(ref, result):
154 # """Gets the next conversation node after \'ref\' given the result
155 # of \'result\'."""
def fixer_lib.sampleNode ( )

Definition at line 103 of file fixer_lib.py.

104 def sampleNode():
105  return "Node2|#a==2^#b==1|\"Aar! This ale is mighty fine. You there, walk the plank!\"|choices|sprite|mouseover^#b==2|\"Land Ahoy!\"|\"bases/fixers/no.spr\"~\"bases/fixers/iso_decline.py\"~\"F Off!\"^\"bases/fixers/yes.spr\"~\"bases/fixers/iso_accept.py\"~\"Sure!\"|sprite|mouseover"
def fixer_lib.setB (   value)

Definition at line 99 of file fixer_lib.py.

99 
100 def setB(value):
101  global b
102  b=value

Variable Documentation

int b = 1

Definition at line 7 of file fixer_lib.py.