From c5413463d627c68f440338c2881e77400577699c Mon Sep 17 00:00:00 2001 From: luxick Date: Thu, 10 Dec 2015 12:00:50 +0100 Subject: [PATCH] Moved all test functions to cli class --- .gitignore | 1 + cli.py | 17 +++++++++++++++-- config.py | 2 -- kinggotchi.py | 9 ++++++++- test.py | 24 +----------------------- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 34fcef1..c0c40b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyo *.pyc +*.swp diff --git a/cli.py b/cli.py index e1b4b41..8d48e4e 100644 --- a/cli.py +++ b/cli.py @@ -1,6 +1,8 @@ #!/usr/bin/python # coding=UTF-8 +from mayorgotchi import Mayorgotchi +from kinggotchi import Kinggotchi from config import * import curses import time @@ -10,8 +12,10 @@ class cursesUI: villagenr = 0 percentage = True running = True - - def __init__(self,start_paused): + ticks = 0 + king = Kinggotchi() + + def __init__(self): self.kingdomview = True self.villagenr = 0 self.percentage = True @@ -26,6 +30,15 @@ class cursesUI: height, width = self.stdscr.getmaxyx() self.win = curses.newpad(16383, width) + + self.king.createKingdom(50) + + while self.running: + self.build_screen(self.king, self.ticks) + + if not self.paused: + self.king.step() + self.ticks += 1 def build_screen(self, king, ticks): diff --git a/config.py b/config.py index 7da0719..43a5746 100644 --- a/config.py +++ b/config.py @@ -5,8 +5,6 @@ ticklenght = 0.001 # Number of Tamagotchis to be created at the start of the simulation startnr = 60 -# The amount of points a Tamagotchi loses per tick -decayaspeed = 1 # If the hunger stat falls below this level Tamagotchis can be fed feeding_point = 50 # If the hygiene stat falls below this level Tamagotchis can be washed diff --git a/kinggotchi.py b/kinggotchi.py index 4d52c06..14c3280 100644 --- a/kinggotchi.py +++ b/kinggotchi.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- from config import * +from mayorgotchi import Mayorgotchi +from util import Util import names +import itertools class Kinggotchi: myvillages = [] @@ -36,4 +39,8 @@ class Kinggotchi: result = 0 for n in self.myvillages: result += n.graveyard - return result \ No newline at end of file + return result + + def createKingdom(self, startvillages): + for _ in itertools.repeat(None, startvillages): + self.add_village(Mayorgotchi(Util().make_list_of_Tamagotchis(startnr))) diff --git a/test.py b/test.py index 990881c..c5f4f7d 100644 --- a/test.py +++ b/test.py @@ -1,28 +1,6 @@ #!/usr/bin/python # coding=UTF-8 -from mayorgotchi import Mayorgotchi -from kinggotchi import Kinggotchi -from util import Util -from config import * from cli import * -import time -import curses -# Temporary test section -ticks = 0 -king = Kinggotchi() -ui = cursesUI(True) - -for n in range(0, 50): - king.add_village(Mayorgotchi(Util().make_list_of_Tamagotchis(startnr))) - -while True: - ui.build_screen(king, ticks) - - if not ui.paused: - king.step() - ticks += 1 - if not ui.running: - break - \ No newline at end of file +ui = cursesUI()