replaced tabs with spaces
This commit is contained in:
@@ -2,43 +2,41 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
from mayorgotchi import Mayorgotchi
|
|
||||||
import names
|
import names
|
||||||
import random
|
|
||||||
|
|
||||||
class Kinggotchi:
|
class Kinggotchi:
|
||||||
myvillages = []
|
myvillages = []
|
||||||
name = ''
|
name = ''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = names.get_last_name()
|
self.name = names.get_last_name()
|
||||||
|
|
||||||
def add_village(self, mayor):
|
def add_village(self, mayor):
|
||||||
self.myvillages.append(mayor)
|
self.myvillages.append(mayor)
|
||||||
|
|
||||||
def show_kingdom(self):
|
def show_kingdom(self):
|
||||||
result = 'I am Kinggotchi '+str(self.name)+'.\nIn my Kingdom live '+str(self.all_tamagotchis())+' Tamagotichs.\nIn my Kingdom '+str(self.all_dead())+' Tamagotchis have died so far.\n\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n'
|
result = 'I am Kinggotchi '+str(self.name)+'.\nIn my Kingdom live '+str(self.all_tamagotchis())+' Tamagotichs.\nIn my Kingdom '+str(self.all_dead())+' Tamagotchis have died so far.\n\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n'
|
||||||
|
|
||||||
for n in self.myvillages:
|
for n in self.myvillages:
|
||||||
# result += '-----------------------------------------------------------------------------------------\n'
|
# result += '-----------------------------------------------------------------------------------------\n'
|
||||||
result += n.give_overview()
|
result += n.give_overview()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
for n in self.myvillages:
|
for n in self.myvillages:
|
||||||
n.step()
|
n.step()
|
||||||
|
|
||||||
def all_tamagotchis(self):
|
def all_tamagotchis(self):
|
||||||
result = 0
|
result = 0
|
||||||
for n in self.myvillages:
|
for n in self.myvillages:
|
||||||
result += len(n.mygotchis)
|
result += len(n.mygotchis)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def all_dead(self):
|
def all_dead(self):
|
||||||
result = 0
|
result = 0
|
||||||
for n in self.myvillages:
|
for n in self.myvillages:
|
||||||
result += n.graveyard
|
result += n.graveyard
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -69,27 +69,27 @@ class Tamagotchi:
|
|||||||
self.power -= 1
|
self.power -= 1
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
self.update_status()
|
self.update_status()
|
||||||
|
|
||||||
if self.status is 'Eating':
|
if self.status is 'Eating':
|
||||||
self.update_stat(self.hunger,True)
|
self.update_stat(self.hunger,True)
|
||||||
else:
|
else:
|
||||||
self.update_stat(self.hunger,False)
|
self.update_stat(self.hunger,False)
|
||||||
|
|
||||||
if self.status is 'Sleeping':
|
if self.status is 'Sleeping':
|
||||||
self.update_stat(self.sleep,True)
|
self.update_stat(self.sleep,True)
|
||||||
else:
|
else:
|
||||||
self.update_stat(self.sleep,False)
|
self.update_stat(self.sleep,False)
|
||||||
|
|
||||||
if self.status is 'Bathing':
|
if self.status is 'Bathing':
|
||||||
self.update_stat(self.hygiene,True)
|
self.update_stat(self.hygiene,True)
|
||||||
else:
|
else:
|
||||||
self.update_stat(self.hygiene,False)
|
self.update_stat(self.hygiene,False)
|
||||||
|
|
||||||
if self.status is 'Playing':
|
if self.status is 'Playing':
|
||||||
self.update_stat(self.happiness,True)
|
self.update_stat(self.happiness,True)
|
||||||
else:
|
else:
|
||||||
self.update_stat(self.happiness,False)
|
self.update_stat(self.happiness,False)
|
||||||
|
|
||||||
def is_dead(self):
|
def is_dead(self):
|
||||||
if self.dead:
|
if self.dead:
|
||||||
|
|||||||
68
test.py
68
test.py
@@ -15,14 +15,14 @@ villagenr = 0
|
|||||||
percentage = True
|
percentage = True
|
||||||
|
|
||||||
def make_list(number):
|
def make_list(number):
|
||||||
list = []
|
tmp = []
|
||||||
for n in range(0,number):
|
for n in range(0,number):
|
||||||
list.append(Util().make_Tamagotchi())
|
tmp.append(Util().make_Tamagotchi())
|
||||||
return list
|
return tmp
|
||||||
|
|
||||||
king = Kinggotchi()
|
king = Kinggotchi()
|
||||||
for n in range(0, 30):
|
for n in range(0, 30):
|
||||||
king.add_village(Mayorgotchi(make_list(startnr)))
|
king.add_village(Mayorgotchi(make_list(startnr)))
|
||||||
|
|
||||||
stdscr = curses.initscr()
|
stdscr = curses.initscr()
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
@@ -34,37 +34,37 @@ height,width = stdscr.getmaxyx()
|
|||||||
win = curses.newpad(16383, width)
|
win = curses.newpad(16383, width)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
win.move(0,0)
|
win.move(0,0)
|
||||||
win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
|
win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
|
||||||
|
|
||||||
if kingdomview:
|
if kingdomview:
|
||||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Village View\n')
|
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Village View\n')
|
||||||
win.addstr(4,0,king.show_kingdom())
|
win.addstr(4,0,king.show_kingdom())
|
||||||
else:
|
else:
|
||||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Kingdom View [n/m]:Previous/Next Village\n')
|
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Kingdom View [n/m]:Previous/Next Village\n')
|
||||||
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
|
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
|
||||||
|
|
||||||
king.step()
|
king.step()
|
||||||
ticks += 1
|
ticks += 1
|
||||||
win.clrtoeol()
|
win.clrtoeol()
|
||||||
win.clrtobot()
|
win.clrtobot()
|
||||||
win.refresh(0, 0, 0, 0, height-1, width-1)
|
win.refresh(0, 0, 0, 0, height-1, width-1)
|
||||||
|
|
||||||
key = stdscr.getch()
|
key = stdscr.getch()
|
||||||
if key == ord('q'):
|
if key == ord('q'):
|
||||||
break
|
break
|
||||||
elif key == ord('p'):
|
elif key == ord('p'):
|
||||||
while True:
|
while True:
|
||||||
unpause_key =stdscr.getch()
|
unpause_key =stdscr.getch()
|
||||||
if unpause_key == ord('p'):
|
if unpause_key == ord('p'):
|
||||||
break
|
break
|
||||||
elif key == ord('v'):
|
elif key == ord('v'):
|
||||||
kingdomview = not kingdomview
|
kingdomview = not kingdomview
|
||||||
elif key == ord('n'):
|
elif key == ord('n'):
|
||||||
villagenr -= 1
|
villagenr -= 1
|
||||||
elif key == ord('m'):
|
elif key == ord('m'):
|
||||||
villagenr += 1
|
villagenr += 1
|
||||||
elif key < 0:
|
elif key < 0:
|
||||||
time.sleep(ticklenght)
|
time.sleep(ticklenght)
|
||||||
|
|
||||||
curses.endwin()
|
curses.endwin()
|
||||||
|
|||||||
Reference in New Issue
Block a user