Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cov.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<coverage version="7.10.7" timestamp="1759105606201" lines-valid="260" lines-covered="0" line-rate="0" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<coverage version="7.10.7" timestamp="1759108727222" lines-valid="260" lines-covered="0" line-rate="0" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.10.7 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
Expand Down
148 changes: 148 additions & 0 deletions src/kreatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self):
self.environment = World()

self.names = [
# Original names
"Jesse",
"Juan",
"Jose",
Expand All @@ -28,6 +29,153 @@ def __init__(self):
"Terry",
"Randy",
"Adam",
# Additional male names
"Alexander",
"Andrew",
"Anthony",
"Austin",
"Benjamin",
"Brandon",
"Brian",
"Christopher",
"Daniel",
"David",
"Edward",
"Ethan",
"Gabriel",
"George",
"Henry",
"Isaac",
"Jacob",
"James",
"Jason",
"John",
"Joseph",
"Joshua",
"Kevin",
"Lucas",
"Matthew",
"Michael",
"Nathan",
"Nicholas",
"Oliver",
"Patrick",
"Richard",
"Robert",
"Samuel",
"Stephen",
"Thomas",
"Timothy",
"Tyler",
"William",
"Zachary",
# Female names
"Abigail",
"Alice",
"Amanda",
"Amy",
"Angela",
"Anna",
"Ashley",
"Barbara",
"Betty",
"Brenda",
"Brittany",
"Carol",
"Catherine",
"Charlotte",
"Christina",
"Christine",
"Deborah",
"Diana",
"Donna",
"Dorothy",
"Elizabeth",
"Emily",
"Emma",
"Grace",
"Hannah",
"Helen",
"Isabella",
"Jessica",
"Jennifer",
"Julie",
"Karen",
"Katherine",
"Kimberly",
"Laura",
"Linda",
"Lisa",
"Margaret",
"Maria",
"Marie",
"Mary",
"Michelle",
"Nancy",
"Nicole",
"Olivia",
"Patricia",
"Rachel",
"Rebecca",
"Ruth",
"Sandra",
"Sarah",
"Sharon",
"Sophia",
"Susan",
"Victoria",
# Modern/diverse names
"Aiden",
"Aria",
"Avery",
"Blake",
"Caleb",
"Chloe",
"Dakota",
"Elijah",
"Felix",
"Harper",
"Hunter",
"Ian",
"Jaxon",
"Liam",
"Luna",
"Madison",
"Mason",
"Maya",
"Mia",
"Noah",
"Owen",
"Parker",
"Quinn",
"Riley",
"Sage",
"Taylor",
"Zoe",
# International names
"Ahmed",
"Aiko",
"Carlos",
"Chen",
"Diego",
"Elena",
"Giovanni",
"Hassan",
"Ivan",
"Jin",
"Kai",
"Lucia",
"Mohammed",
"Natasha",
"Oscar",
"Pierre",
"Raj",
"Sofia",
"Takeshi",
"Valentina",
"Wei",
"Yuki",
"Zara",
]

print("What would you like to name your kreature?")
Expand Down
98 changes: 98 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright (c) 2022 Daniel McCoy Stephenson
# Apache License 2.0

import sys
import os
import unittest
from unittest.mock import patch

# Add src to path to import modules
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))

from entity.livingEntity import LivingEntity


class TestKreaturesIntegration(unittest.TestCase):
"""Integration test to verify the game works with expanded names"""

@patch("builtins.input", return_value="TestPlayer")
@patch("builtins.print")
def setUp(self, mock_print, mock_input):
"""Set up test environment"""
from kreatures import Kreatures

self.kreatures = Kreatures()

def test_create_multiple_entities_have_different_names(self):
"""Test that creating multiple entities can result in different names"""
# Create several entities and collect their names
entity_names = set()
for _ in range(20):
self.kreatures.createEntity()

# Get names of all entities (excluding player creature and starter entities)
# Filter out non-LivingEntity objects (like the "placeholder" string)
for entity in self.kreatures.environment.getEntities():
if hasattr(entity, "name") and entity != self.kreatures.playerCreature:
entity_names.add(entity.name)

# With 159 names available, we should see some variety
# Even with random selection, getting 20+ different names should be likely
self.assertGreater(
len(entity_names), 1, "Should have at least some name variety"
)

def test_child_entities_get_names_from_expanded_list(self):
"""Test that child entities use names from the expanded list"""
parent1 = LivingEntity("Parent1")
parent2 = LivingEntity("Parent2")

# Create multiple children to test name variety
child_names = set()
for _ in range(10):
child = self.kreatures.createChildEntity(parent1, parent2)
child_names.add(child.name)
# Remove child to avoid cluttering the environment
self.kreatures.environment.removeEntity(child)

# All child names should be from our expanded list
for name in child_names:
self.assertIn(name, self.kreatures.names)

# With 159 names, we should get some variety
self.assertGreaterEqual(len(child_names), 1)

def test_world_starter_entities_still_work(self):
"""Test that the world still initializes with starter entities correctly"""
entities = self.kreatures.environment.getEntities()

# Should have player creature plus starter entities from world
self.assertGreater(len(entities), 1)

# Verify starter entities have valid names
starter_names = [
"Alison",
"Barry",
"Conrad",
"Derrick",
"Eric",
"Francis",
"Gary",
"Harry",
"Isabelle",
"Jasper",
]

# Filter out non-LivingEntity objects (like the "placeholder" string)
found_starter_names = [
entity.name
for entity in entities
if hasattr(entity, "name") and entity.name in starter_names
]
self.assertGreater(
len(found_starter_names), 0, "Should find some starter entities"
)


if __name__ == "__main__":
unittest.main()
Loading