Test character class without tickerhandler
This commit is contained in:
parent
dc67f4b871
commit
b213f4a243
2 changed files with 15 additions and 6 deletions
|
|
@ -1229,8 +1229,8 @@ class TestTurnBattleFunc(EvenniaTest):
|
||||||
|
|
||||||
# Test functions in tb_items.
|
# Test functions in tb_items.
|
||||||
def test_tbitemsfunc(self):
|
def test_tbitemsfunc(self):
|
||||||
attacker = create_object(tb_items.TBItemsCharacter, key="Attacker")
|
attacker = create_object(tb_items.TBItemsCharacterTest, key="Attacker")
|
||||||
defender = create_object(tb_items.TBItemsCharacter, key="Defender")
|
defender = create_object(tb_items.TBItemsCharacterTest, key="Defender")
|
||||||
testroom = create_object(DefaultRoom, key="Test Room")
|
testroom = create_object(DefaultRoom, key="Test Room")
|
||||||
attacker.location = testroom
|
attacker.location = testroom
|
||||||
defender.loaction = testroom
|
defender.loaction = testroom
|
||||||
|
|
@ -1297,7 +1297,7 @@ class TestTurnBattleFunc(EvenniaTest):
|
||||||
turnhandler.turn_end_check(attacker)
|
turnhandler.turn_end_check(attacker)
|
||||||
self.assertTrue(turnhandler.db.turn == 1)
|
self.assertTrue(turnhandler.db.turn == 1)
|
||||||
# Join fight
|
# Join fight
|
||||||
joiner = create_object(tb_items.TBItemsCharacter, key="Joiner")
|
joiner = create_object(tb_items.TBItemsCharacterTest, key="Joiner")
|
||||||
turnhandler.db.fighters = [attacker, defender]
|
turnhandler.db.fighters = [attacker, defender]
|
||||||
turnhandler.db.turn = 0
|
turnhandler.db.turn = 0
|
||||||
turnhandler.join_fight(joiner)
|
turnhandler.join_fight(joiner)
|
||||||
|
|
@ -1306,8 +1306,7 @@ class TestTurnBattleFunc(EvenniaTest):
|
||||||
# Remove the script at the end
|
# Remove the script at the end
|
||||||
turnhandler.stop()
|
turnhandler.stop()
|
||||||
# Now time to test item stuff.
|
# Now time to test item stuff.
|
||||||
user = create_object(tb_items.TBItemsCharacter, key="User")
|
user = create_object(tb_items.TBItemsCharacterTest, key="User")
|
||||||
tb_items.tickerhandler.remove(interval=30, callback=user.at_update, idstring="update")
|
|
||||||
testroom = create_object(DefaultRoom, key="Test Room")
|
testroom = create_object(DefaultRoom, key="Test Room")
|
||||||
user.location = testroom
|
user.location = testroom
|
||||||
test_healpotion = create_object(key="healing potion")
|
test_healpotion = create_object(key="healing potion")
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,16 @@ class TBItemsCharacter(DefaultCharacter):
|
||||||
# Tick down condition durations
|
# Tick down condition durations
|
||||||
condition_tickdown(self, self)
|
condition_tickdown(self, self)
|
||||||
|
|
||||||
|
class TBItemsCharacterTest(TBItemsCharacter):
|
||||||
|
"""
|
||||||
|
Just like the TBItemsCharacter, but doesn't subscribe to the TickerHandler.
|
||||||
|
This makes it easier to run unit tests on.
|
||||||
|
"""
|
||||||
|
def at_object_creation(self):
|
||||||
|
self.db.max_hp = 100 # Set maximum HP to 100
|
||||||
|
self.db.hp = self.db.max_hp # Set current HP to maximum
|
||||||
|
self.db.conditions = {} # Set empty dict for conditions
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue