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:
parent
8fa1664bcb
commit
5ea17719be
5 changed files with 104 additions and 35 deletions
|
|
@ -1,31 +1,23 @@
|
|||
load "mongo_connect.rb"
|
||||
load "mongo_document_wrapper.rb"
|
||||
load "sqlite_connect.rb"
|
||||
load "active_sqlite_record.rb"
|
||||
load "entity_factory.rb"
|
||||
|
||||
load "rpg_grid.rb"
|
||||
load "rpg_bets.rb"
|
||||
|
||||
class ActiveRpg
|
||||
@grid = nil
|
||||
@mc = nil
|
||||
@sc = nil
|
||||
@ef = nil
|
||||
|
||||
def initialize(grid_size = 10, db="testdb", coll="entities")
|
||||
@mc = MongoConnect.new(db, coll)
|
||||
@ef = EntityFactory.new(@mc)
|
||||
@grid = RpgGrid.new(@mc, grid_size)
|
||||
@bets = RpgBets.new(@mc)
|
||||
def initialize(grid_size = 10, db="testdb")
|
||||
@sc = SQLiteConnect.new(db)
|
||||
@ef = EntityFactory.new(@sc)
|
||||
@grid = RpgGrid.new(@sc, grid_size)
|
||||
end
|
||||
|
||||
# this should only really ever be needed in a simulation run to clear out the DB and reset the indexes
|
||||
def get_mc()
|
||||
return @mc
|
||||
end
|
||||
|
||||
# this is just a placeholder hopefully. need to flesh out how bets are gonna work but gonna
|
||||
# delegate it to the irc bot for now...
|
||||
def get_bets()
|
||||
return @bets
|
||||
def get_sc()
|
||||
return @sc
|
||||
end
|
||||
|
||||
# Create and/or load player. Spawn another entity. Move the player.
|
||||
|
|
@ -56,7 +48,9 @@ class ActiveRpg
|
|||
end
|
||||
|
||||
def find_player(player_name)
|
||||
found_player = @mc.collection.find({"type" => :player, "name" => player_name}).first
|
||||
found_player = @sc.execute("
|
||||
SELECT * FROM players WHERE player_name = #{player_name}
|
||||
").first
|
||||
|
||||
if found_player == nil then
|
||||
p = @ef.get(:player)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue