Hopefully getting the database to init and reset itself (in testground.rb, need to make that more of a active_rpg.rb thing...
This commit is contained in:
parent
3579f47eda
commit
d81c397629
7 changed files with 35 additions and 25 deletions
|
|
@ -5,18 +5,24 @@
|
|||
load "active_rpg.rb"
|
||||
|
||||
#configgy bits
|
||||
collection_name = "testground"
|
||||
db_name = "testground"
|
||||
grid_size = 25
|
||||
player_num = 20
|
||||
turns = 1000
|
||||
max_damage = 100
|
||||
|
||||
$ar = nil # ActigeRpg instance
|
||||
$bets = nil
|
||||
|
||||
# call this if you want to drop all of the DB.
|
||||
def reset_all()
|
||||
puts $ar.inspect
|
||||
puts "Trying to null out the players/entities tables..."
|
||||
sql = $ar.get_sql_connect
|
||||
puts sql.inspect
|
||||
sql.query("DROP TABLE IF EXISTS players;")
|
||||
sql.query("DROP TABLE IF EXISTS entities;")
|
||||
|
||||
sql.query("CREATE TABLE players(id INT PRIMARY KEY, name TEXT NOT NULL UNIQUE);")
|
||||
sql.query("CREATE TABLE entities(id INT PRIMARY KEY);")
|
||||
end
|
||||
|
||||
# generates a line of given length.
|
||||
|
|
@ -26,11 +32,11 @@ end
|
|||
|
||||
# start of simulator code
|
||||
|
||||
puts "Starting run in collection " + collection_name + ", " + grid_size.to_s + " grid."
|
||||
puts "Starting run in collection " + db_name + ", " + grid_size.to_s + " grid."
|
||||
puts player_num.to_s + " players, " + turns.to_s + " turns, " + max_damage.to_s + " max damage."
|
||||
|
||||
puts "Creating ActiveRpg"
|
||||
$ar = ActiveRpg.new(grid_size, collection_name)
|
||||
$ar = ActiveRpg.new(grid_size, db_name)
|
||||
|
||||
puts "Dropping and building index on the collection"
|
||||
reset_all()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue