侏罗纪世界:进化 2
单机游戏
在饥荒这款中,玩家需要通过在荒野中采源、建造基地、研究科技等方式来生存下去。而腐植物则是一种非常特殊植物,它可以通过吞噬玩家垃圾来生长,并且可以提供一些有用物品。下面是腐植物代码实现:
实现思路
腐植物实现思路较为简单,主要是通过一些基逻辑判断来模拟植物生长过程。具体实现过程如下:
代码实现
下面是腐植物具体代码实现,其中包括了上述实现思路中各个步骤:
class RotPlant:
def __init__(self, health, stage, gwth_time):
self.health = health
self.stage = stage
self.gwth_time = gwth_time
def gw(self, trash):
if trash.type == \tten\ if self.stage == 1 and trash.amount >= 1:
self.health = 10
self.stage = 1
self.gwth_time = 10
trash.amount -= 1
elif self.stage == 2 and trash.amount >= 2:
self.health = 20
self.stage = 1
self.gwth_time = 20
trash.amount -= 2
elif self.stage == 3 and trash.amount >= 3:
self.health = 30
self.stage = 1
self.gwth_time = 30
trash.amount -= 3
def die(self):
if self.health