And I started implementing my current project's characters as objects directly in python. The class-methods i described all worked just fine.
I then used the same code directly on my script, under a init python block. It worked fine enough that methods returned what was expected of them.
However, as expected, some things were left out, like couple o lines of text I wanted to display to user along the execution of the method. Like in the following method of my Hero class that describes a combatsys:
Code: Select all
def fightEnemy(self, enemy, **events):
CRT = [[[3, 5], [4, 5], [5, 4], [6, 4], [7, 4], [8, 3], [9, 3], [0, 'k'], [0, 'k'], [0, 8], [0, 6], [1, 6], [2, 5]],
[[4, 4], [5, 4], [6, 3], [7, 3], [8, 3], [9, 3], [10, 2], [0, 'k'], [0, 8], [0, 7], [1, 6], [2, 5], [3, 5]],
[[5, 4], [6, 3], [7, 3], [8, 3], [9, 2], [10, 2], [11, 2], [0, 8], [0, 7], [1, 6], [2, 5], [3, 5], [4, 4]],
[[6, 3], [7, 3], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 4 ]],
[[7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [14, 1], [1, 7], [2, 6], [3, 5], [4, 4], [5, 4], [6, 3]],
[[8, 2], [9, 2], [10, 2], [11, 1], [12, 1], [14, 1], [16, 1], [2, 6], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2]],
[[9, 1], [10, 1], [11, 1], [12, 0], [14, 0], [16, 0], [18, 0], [3, 5], [4, 5], [5, 4], [6, 3], [7, 2], [8, 2]],
[[10, 0], [11, 0], [12, 0], [14, 0], [16, 0], [18, 0], ['k', 0], [4, 4], [5, 4], [6, 3], [7, 2], [8, 1], [9, 1]],
[[11, 0], [12, 0], [14, 0], [16, 0], [18, 0], ['k', 0], ['k', 0], [5, 3], [6, 3], [7, 2], [8, 0], [9, 0], [10, 0]],
[[12, 0], [14, 0], [16, 0], [18, 0], ['k', 0], ['k', 0], ['k', 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0]]]
rounds = 1
CR = self.CS - enemy.CS
print 'CR =', CR
if CR > 0:
CR = (CR + 1) / 2
else:
CR = CR / 2
while self.EP > 0 and enemy.EP > 0:
print 'Hero CS:', self.CS, '|Hero EP:', self.EP
print 'Enemy CS:', enemy.CS, '|Enemy EP:', enemy.EP
randomNumber = self.pickRandomNumber()
print 'Random Number Picked:', randomNumber
print 'Random CRT Cell:', CRT[randomNumber][CR]
enemy.takeDMG(CRT[randomNumber][CR][0])
if enemy.EP <= 0:
return '---Win!---'
self.takeDMG(CRT[CR][randomNumber][1])
if self.EP <= 0:
return '---Lose!---'
for key in events:
if rounds == events[key][0]:
return events[key][1]
rounds += 1
But in the end, I want to display some lines of text during combat, portraying the results of each round of combat.
So what I would like to know though is: can this be done with Ren'Py code alone or can python and ren'py be mixed for such end-result? how would I go about doing that?