Comments (2)
Here are some mandatory navigation tests that should be integrated into whatever testbed is developed:
Using configuration:
player:
class:
- Mage
- Barbarian
- Paladin
monster:
- name: Hellhound
strength: 2
health: 10
- name: Wizard
strength: 4
health: 20
map:
- name: West Dungeon
monsters:
- Hellhound
dim:
xMin: 0
yMin: 0
xMax: 200
yMax: 200
- name: Central Dungeon
monsters:
- Wizard
dim:
xMin: 201
yMin: 100
xMax: 400
yMax: 300
- name: East Dungeon
monsters:
- Wizard
dim:
xMin: 401
yMin: 0
xMax: 600
yMax: 300
- name: North Dungeon
monsters:
- Wizard
dim:
xMin: 300
yMin: 301
xMax: 450
yMax: 500
- name: South Dungeon
monsters:
- Wizard
dim:
xMin: 250
yMin: 50
xMax: 380
yMax: 99
from game.user import User, BadMove
from game.map import Location, Map
xyz = {'name': 'Bob', 'health': 100, 'strength': 100}
### LEFT/RIGHT
# WEST TO CENTRAL
bob = User(cls='Paladin', key='key', location=Location(mp=Map.get('West Dungeon'), x=200, y=198), **xyz)
bob.move('e')
assert bob.location.map.name == 'Central Dungeon'
assert bob.location.x == 0
assert bob.location.y == 98
# CENTRAL TO EAST
bob.location = Location(mp=Map.get('Central Dungeon'), x=199, y=198)
bob.move('e')
assert bob.location.map.name == 'East Dungeon'
assert bob.location.x == 0
assert bob.location.y == 298
# EAST TO CENTRAL
bob.location = Location(mp=Map.get('East Dungeon'), x=0, y=198)
bob.move('w')
assert bob.location.map.name == 'Central Dungeon'
assert bob.location.x == 199
assert bob.location.y == 98
### UP/ DOWN
# MIDDLE OF CENTRAL
bob.location = Location(mp=Map.get('Central Dungeon'), x=50, y=50)
bob.move('n')
assert bob.location.map.name == 'Central Dungeon'
assert bob.location.x == 50
assert bob.location.y == 51
# CENTRAL TO NORTH
bob.location = Location(mp=Map.get('Central Dungeon'), x=105, y=200)
bob.move('n')
assert bob.location.map.name == 'North Dungeon'
assert bob.location.x == 6
assert bob.location.y == 0
# CENTRAL TO SOUTH
bob.location = Location(mp=Map.get('Central Dungeon'), x=150, y=0)
bob.move('s')
assert bob.location.map.name == 'South Dungeon'
assert bob.location.x == 101
assert bob.location.y == 49
# EAST TO NORTH
bob.location = Location(mp=Map.get('East Dungeon'), x=40, y=300)
bob.move('n')
assert bob.location.map.name == 'North Dungeon'
assert bob.location.x == 141
assert bob.location.y == 0
# MULTIMAP CORNER WALK
bob.location = Location(mp=Map.get('Central Dungeon'), x=199, y=200)
bob.move('n')
assert bob.location.map.name == 'North Dungeon'
assert bob.location.x == 100
assert bob.location.y == 0
bob.move('e')
assert bob.location.map.name == 'North Dungeon'
assert bob.location.x == 101
assert bob.location.y == 0
bob.move('s')
assert bob.location.map.name == 'East Dungeon'
assert bob.location.x == 0
assert bob.location.y == 300
bob.move('w')
assert bob.location.map.name == 'Central Dungeon'
assert bob.location.x == 199
assert bob.location.y == 200
### EDGE/BOUNDARY (LITERAL) CASES
# NORTH, NO NEIGHBOR
bob.location = Location(mp=Map.get('North Dungeon'), x=75, y=199)
try:
bob.move('n')
raise Exception('Should have failed!')
except Exception as error:
assert type(error) is BadMove
# SOUTH, NO NEIGHBOR
bob.location = Location(mp=Map.get('South Dungeon'), x=100, y=0)
try:
bob.move('s')
raise Exception('Should have failed!')
except Exception as error:
assert type(error) is BadMove
# WEST, NO NEIGHBOR
bob.location = Location(mp=Map.get('West Dungeon'), x=0, y=50)
try:
bob.move('w')
raise Exception('Should have failed!')
except Exception as error:
assert type(error) is BadMove
# EAST, NO NEIGHBOR
bob.location = Location(mp=Map.get('East Dungeon'), x=199, y=299)
try:
bob.move('e')
raise Exception('Should have failed!')
except Exception as error:
assert type(error) is BadMove
from crystal-skull.
Some other great ideas for tests:
- All constructors.
- Results of constructors ->
to_cfg
/db
(whichever applicable) ->from_cfg
/db
, ensure same contents.- Confirm that, for example,
Map
references indeed refer to the same object, since one of the key points is to avoid duplication of data in memory.
- Confirm that, for example,
from crystal-skull.
Related Issues (9)
- General enhancements HOT 2
- Fix up CI HOT 1
- Consider mongoengine HOT 2
- Add YAML validation HOT 3
- Implement initial game loop HOT 3
- Implement initial battle system
- Implement initial user stats HOT 2
- Implement initial exploration system HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal-skull.