示例#1
0
 public DecayDaemon(DataSQLite db, Clients clients)
 {
     _db = db;
     _clients = clients;
     _decays = new List<DecayDefinition>();
     _timer = new Timer(DoDecays, null, 0, 5000);
 }
示例#2
0
        public Startup(IHostingEnvironment env)
        {
            _db = new DataSQLite();
            _server = new GameServer(_db);

            var builder = new ConfigurationBuilder();

            Configuration = builder.Build();
        }
示例#3
0
 public void CreateBody_WithInvalidTemplateString_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         var body = db.CreateBody("invalid template string");
         Assert.Null(body);
         Assert.Empty(db.Bodies());
     }
 }
示例#4
0
        public GameServer(DataSQLite db)
        {
            _db = db;

            Cmd.Db = db;

            _clients = new Clients(_db);

            Cmd.Clients = _clients;

            Do.Clients = _clients;

            _spawnDaemon = new SpawnDaemon(_db, _clients);

            _decayDaemon = new DecayDaemon(_db, _clients);

            _regenDaemon = new RegenDaemon(_db, _clients);
            
            _npcDaemon = new NpcDaemon(_db, _clients);
        }
示例#5
0
 public void CreateBody_WithEmptyTemplateString_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         {
             var body = db.CreateBody(null);
             Assert.Null(body);
             Assert.Empty(db.Bodies());
         }
         {
             var body = db.CreateBody("");
             Assert.Null(body);
             Assert.Empty(db.Bodies());
         }
         {
             var body = db.CreateBody(" \t");
             Assert.Null(body);
             Assert.Empty(db.Bodies());
         }
     }
 }
示例#6
0
 public void AddRoleToEntity_Persists()
 {
     using (var db = new DataSQLite())
     {
         string role = "testrole";
         string itemId;
         {
             var item = db.CreateItem("item-chair");
             itemId = item.Id;
             Assert.False(db.HasRole(itemId, role));
             db.AddRoleToEntity(itemId, role);
             Assert.True(db.HasRole(itemId, role));
         }
         {
             var item = db.Item(itemId);
             Assert.True(db.HasRole(itemId, role));
             db.DeleteItem(itemId);
             Assert.False(db.HasRole(itemId, role));
             Assert.Empty(db.Items());
         }
     }
 }
示例#7
0
 public NpcDaemon(DataSQLite db, Clients clients)
 {
     _db = db;
     _clients = clients;
     _timer = new Timer(OnTick, null, 0, 5000);
 }
示例#8
0
 public RegenDaemon(DataSQLite db, Clients clients)
 {
     _db = db;
     _clients = clients;
     _timer = new Timer(DoRegens, null, 0, 5000);
 }
示例#9
0
 public void CreateItem_WithEmptyTemplateString_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         {
             var item = db.CreateItem(null);
             Assert.Null(item);
             Assert.Empty(db.Items());
         }
         {
             var item = db.CreateItem("");
             Assert.Null(item);
             Assert.Empty(db.Items());
         }
         {
             var item = db.CreateItem(" \t");
             Assert.Null(item);
             Assert.Empty(db.Items());
         }
     }
 }
示例#10
0
文件: Daemon.cs 项目: McBits/DungeonR
 static Daemon()
 {
     _db = new DataSQLite();
     _decays = new List<DecayDefinition>();
 }
示例#11
0
        public void DeleteBody_DeletesBody()
        {
            using (var db = new DataSQLite())
            {
                var monster = db.CreateBody("body-monster");
                Assert.NotEmpty(db.Bodies());

                db.DeleteBody(monster.Id);
                Assert.Empty(db.Bodies());

                var guard = db.CreateBody("body-guard");
                Assert.NotEmpty(db.Bodies());

                db.DeleteBody(guard.Id);
                Assert.Empty(db.Bodies());
            }
        }
示例#12
0
        public void DeleteItem_AlsoDeletesRoles()
        {
            using (var db = new DataSQLite())
            {
                var item = db.CreateItem("item-chair");
                var itemId = item.Id;
                Assert.True(db.HasRole(itemId, "seat"));

                db.DeleteItem(item.Id);
                Assert.False(db.HasRole(itemId, "seat"));
                Assert.Empty(db.RolesByEntity(itemId));

                Assert.Empty(db.Items());
            }
        }
示例#13
0
 public Clients(DataSQLite db)
 {
     _db = db;
 }
示例#14
0
 public HeartbeatDaemon(DataSQLite db, Clients clients)
 {
     _db = db;
     _clients = clients;
     _heartbeatTimer = new Timer(HeartbeatTimer_Elapsed, null, 0, 5000);
 }
示例#15
0
        public void DeleteItem_DeletesItem()
        {
            using (var db = new DataSQLite())
            {
                var weapon = db.CreateItem("item-weapon");
                Assert.NotEmpty(db.Items());

                db.DeleteItem(weapon.Id);
                Assert.Empty(db.Items());
            }
        }
示例#16
0
 public void GetScene_InvalidId_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         var scene = db.Scene("invalid ID");
         Assert.Null(scene);
     }
 }
示例#17
0
 public void GetScene_EmptyId_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         {
             var scene = db.Scene(null);
             Assert.Null(scene);
         }
         {
             var scene = db.Scene("");
             Assert.Null(scene);
         }
         {
             var scene = db.Scene(" ");
             Assert.Null(scene);
         }
     }
 }
示例#18
0
 public void GetAllItemSpawnsTest()
 {
     using (var db = new DataSQLite())
     {
         var spawns = db.ItemSpawns();
         Assert.NotEmpty(spawns);
         Assert.Contains(spawns, s => s.SceneId == "scene-1" && s.TemplateId == "item-chair" && s.MaxSpawns == 1);
     }
 }
示例#19
0
 public void GetAllBodySpawnsTest()
 {
     using (var db = new DataSQLite())
     {
         var spawns = db.BodySpawns();
         Assert.NotEmpty(spawns);
         Assert.Contains(spawns, s => s.SceneId == "scene-1" && s.TemplateId == "body-healer" && s.MaxSpawns == 1);
     }
 }
示例#20
0
 public Heartbeat(DataSQLite db)
 {
     _db = db;
     _heartbeatTimer = new Timer(HeartbeatTimer_Elapsed, null, 0, 5000);
 }
示例#21
0
 public void SetEntityName_InvalidEntity()
 {
     using (var db = new DataSQLite())
     {
         db.SetName("invalid ID", "a name");
     }
 }
示例#22
0
        public GameServer()
        {
            Daemon.StartDaemon();
			_db = new DataSQLite();
        }
示例#23
0
 public void CreateItem_WithInvalidTemplateString_ReturnsNull()
 {
     using (var db = new DataSQLite())
     {
         var item = db.CreateItem("invalid template string");
         Assert.Null(item);
         Assert.Empty(db.Items());
     }
 }
示例#24
0
 public void SetGender_InvalidBody()
 {
     using (var db = new DataSQLite())
     {
         db.SetGender("invalid ID", Gender.Female);
     }
 }
示例#25
0
        public void DeleteBody_AlsoDeletesRoles()
        {
            using (var db = new DataSQLite())
            {
                var body = db.CreateBody("body-player");
                var bodyId = body.Id;
                Assert.True(db.HasRole(bodyId, "player"));

                db.DeleteBody(body.Id);
                Assert.False(db.HasRole(bodyId, "player"));
                Assert.Empty(db.RolesByEntity(bodyId));

                Assert.Empty(db.Bodies());
            }
        }