Trying to shoe-horn in sqlite. This needs a lot of work. SQLiteConnect needs to initialize itself... reset tables on command and build new ones. Then start hacking at EntityFactory to get active records back.

This commit is contained in:
Alex Stevenson 2025-07-16 23:13:07 -04:00
parent 8fa1664bcb
commit 5ea17719be
5 changed files with 104 additions and 35 deletions

View file

@ -16,8 +16,7 @@ $bets = nil
# call this if you want to drop all of the DB.
def reset_all()
$ar.get_mc().collection.drop()
$ar.get_mc().collection().indexes.create_one(_id: 1)
puts $ar.inspect
end
# generates a line of given length.
@ -25,18 +24,6 @@ def get_line(len)
line = Array.new(1+rand(len), ".").join
end
# I want to find a way to make it a bit more dynamic in
# adding bets here.... More variations
def place_bet(player, target)
chance = rand(1000)
if chance <= 2 then
amount = 1+rand(10)
puts $bets.place_bet(player, target, amount)
end
end
# start of simulator code
puts "Starting run in collection " + collection_name + ", " + grid_size.to_s + " grid."
@ -45,9 +32,6 @@ puts player_num.to_s + " players, " + turns.to_s + " turns, " + max_damage.to_s
puts "Creating ActiveRpg"
$ar = ActiveRpg.new(grid_size, collection_name)
puts "Grabbing bets..."
$bets = $ar.get_bets()
puts "Dropping and building index on the collection"
reset_all()