python Renpy的统计类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Renpy的统计类相关的知识,希望对你有一定的参考价值。
class Stat(object):
class Delta(object):
def __init__(self, parent):
self.parent = parent
self.value = parent.value
def __repr__(self):
return '<Stat.Delta value={}>'.format(self.calculate())
def __str__(self):
return str(self.calculate())
def calculate(self):
delta = self.parent.value - self.value
if self.parent.dir == 'down': delta *= -1
return delta
def is_positive(self): return self.calculate > 0
def is_negative(self): return self.calculate < 0
def is_zero(self): return self.calculate == 0
def reset(self): self.value = self.parent.value
def __init__(self, name, value, max, min):
self.name = name
self.value = value
self.max = max
self.min = min
self.dir = dir
self.delta = self.Delta(self)
def __repr__(self):
return '<Stat "{}" value={} delta={}>'.format(self.name, self.value, self.delta)
def __str__(self):
return str(self.value)
def __add__(self, value):
self.value += value
return self.value
def __sub__(self, value):
self.value -= value
return self.value
def __eq__(self, other): return self.value == other
def __ne__(self, other): return self.value != other
def __lt__(self, other): return self.value < other
def __le__(self, other): return self.value <= other
def __gt__(self, other): return self.value > other
def __ge__(self, other): return self.value >= other
strength = Stat('Strength', 20, 0, 100)
print repr(strength)
print repr(strength.delta)
print strength + 6
print strength.delta
print repr(strength)
print strength - 8
print strength.delta
print repr(strength)
strength.delta.reset()
print repr(strength)
以上是关于python Renpy的统计类的主要内容,如果未能解决你的问题,请参考以下文章
为啥 buildozer 显示 Error: Activity class org.test.myapp/org.renpy.android.PythonActivity 不存在
Python - Pickle init需要4个参数 - 给出1个
android上的Python [重复]
基于 Python 文本的 rpg 类统计
Python爬虫练习(拉勾网北京地区数据挖掘类职位所需技能统计)
10个Python 统计报表/图表图形类库