public void SnapLootedResources(BattleOwner owner, uint groupId, uint battleId, Resource lootResource, Resource bonusResource) { }
public void AddAccess(BattleOwner owner, BattleManager.BattleSide battleSide) { battleReportWriter.SnapBattleAccess(battle.BattleId, owner, 0, 0, battleSide == BattleManager.BattleSide.Attack); }
public void SetLootedResources(BattleOwner owner, uint groupId, uint battleId, Resource lootResource, Resource bonusResource) { battleReportWriter.SnapLootedResources(owner, groupId, battleId, lootResource, bonusResource); }
public void SnapLootedResources(BattleOwner owner, uint groupId, uint battleId, Resource lootResource, Resource bonusResource) { uint reportViewId; using ( var reader = dbManager.ReaderQuery( string.Format( @"SELECT `id` as `report_view_id` FROM `{0}` WHERE `owner_type` = @owner_type AND `owner_id` = @owner_id AND `battle_id` = @battle_id AND `group_id` = @group_id", BATTLE_REPORT_VIEWS_DB), new[] { new DbColumn("owner_type", owner.Type.ToString(), DbType.String), new DbColumn("owner_id", owner.Id.ToString(), DbType.UInt32), new DbColumn("battle_id", battleId, DbType.UInt32), new DbColumn("group_id", groupId, DbType.UInt32) })) { if (!reader.HasRows) { throw new Exception("Could not find report we're trying to update"); } reader.Read(); reportViewId = (uint)reader["report_view_id"]; } dbManager.Query(string.Format(@"UPDATE `{0}` SET `loot_wood` = @wood, `loot_gold` = @gold, `loot_crop` = @crop, `loot_iron` = @iron, `bonus_wood` = @bonus_wood, `bonus_gold` = @bonus_gold, `bonus_crop` = @bonus_crop, `bonus_iron` = @bonus_iron WHERE `id` = @id", BATTLE_REPORT_VIEWS_DB), new[] { new DbColumn("wood", lootResource.Wood, DbType.Int32), new DbColumn("crop", lootResource.Crop, DbType.Int32), new DbColumn("iron", lootResource.Iron, DbType.Int32), new DbColumn("gold", lootResource.Gold, DbType.Int32), new DbColumn("bonus_wood", bonusResource.Wood, DbType.Int32), new DbColumn("bonus_crop", bonusResource.Crop, DbType.Int32), new DbColumn("bonus_iron", bonusResource.Iron, DbType.Int32), new DbColumn("bonus_gold", bonusResource.Gold, DbType.Int32), new DbColumn("id", reportViewId, DbType.UInt32) }); }
public void SnapBattleAccess(uint battleId, BattleOwner owner, ushort troopId, uint groupId, bool isAttacker) { dbManager.Query(string.Format(@"INSERT INTO `{0}` VALUES ('', @owner_type, @owner_id, @troop_id, @battle_id, @object_id, @is_attacker, 0, 0, 0, 0, 0, 0, 0, 0, 0, UTC_TIMESTAMP())", BATTLE_REPORT_VIEWS_DB), new[] { new DbColumn("owner_type", owner.Type, DbType.String), new DbColumn("owner_id", owner.Id, DbType.UInt32), new DbColumn("troop_id", troopId, DbType.UInt16), new DbColumn("battle_id", battleId, DbType.UInt32), new DbColumn("object_id", groupId, DbType.UInt32), new DbColumn("is_attacker", isAttacker, DbType.Boolean) }); }
public void SnapBattle(uint battleId, BattleOwner owner, BattleLocation location) { dbManager.Query( string.Format( @"INSERT INTO `{0}` VALUES (@id, @owner_type, @owner_id, @location_type, @location_id, UTC_TIMESTAMP(), NULL, '0')", BATTLE_DB), new[] { new DbColumn("id", battleId, DbType.UInt32), new DbColumn("owner_type", owner.Type.ToString(), DbType.String, 15), new DbColumn("owner_id", owner.Id, DbType.UInt32), new DbColumn("location_type", location.Type.ToString(), DbType.String, 15), new DbColumn("location_id", location.Id, DbType.UInt32) }); }
public virtual void JoinOrCreateBarbarianTribeBattle(IBarbarianTribe barbarianTribe, ITroopObject attackerTroopObject, out ICombatGroup combatGroup, out uint battleId) { // If battle already exists, then we just join it in also bringing any new units if (barbarianTribe.Battle != null) { combatGroup = battleProcedure.AddAttackerToBattle(barbarianTribe.Battle, attackerTroopObject); } // Otherwise, the battle has to be created else { var battleOwner = new BattleOwner(BattleOwnerType.BarbarianTribe, barbarianTribe.ObjectId); barbarianTribe.Battle = battleManagerFactory.CreateBarbarianBattleManager(new BattleLocation(BattleLocationType.BarbarianTribe, barbarianTribe.ObjectId), battleOwner, barbarianTribe); combatGroup = battleProcedure.AddAttackerToBattle(barbarianTribe.Battle, attackerTroopObject); var battlePassiveAction = actionFactory.CreateBarbarianTribeBattlePassiveAction(barbarianTribe.ObjectId); Error result = barbarianTribe.Worker.DoPassive(barbarianTribe, battlePassiveAction, false); if (result != Error.Ok) { throw new Exception(string.Format("Failed to start a battle due to error {0}", result)); } barbarianTribe.BeginUpdate(); barbarianTribe.LastAttacked = DateTime.UtcNow; barbarianTribe.State = GameObjectStateFactory.BattleState(barbarianTribe.Battle.BattleId); barbarianTribe.EndUpdate(); } battleId = barbarianTribe.Battle.BattleId; }
public BarbarianTribeCombatGroup(uint battleId, uint id, IBarbarianTribe barbarianTribe, IDbManager dbManager) : base(battleId, id, dbManager) { this.barbarianTribe = barbarianTribe; owner = new BattleOwner(BattleOwnerType.BarbarianTribe, barbarianTribe.ObjectId); }
public StrongholdCombatGroup(uint battleId, uint id, IStronghold stronghold, IDbManager dbManager) : base(battleId, id, dbManager) { this.stronghold = stronghold; owner = new BattleOwner(BattleOwnerType.Stronghold, stronghold.ObjectId); }
public CityOffensiveCombatGroup(uint battleId, uint id, ITroopObject troopObject, IDbManager dbManager) : base(battleId, id, dbManager) { owner = new BattleOwner(BattleOwnerType.City, troopObject.City.Id); TroopObject = troopObject; }
public CityDefensiveCombatGroup(uint battleId, uint id, ITroopStub troopStub, IDbManager dbManager) : base(battleId, id, dbManager) { owner = new BattleOwner(BattleOwnerType.City, troopStub.City.Id); TroopStub = troopStub; }
public void SnapBattle(uint battleId, BattleOwner owner, BattleLocation location) { }
public void SnapBattleAccess(uint battleId, BattleOwner owner, ushort troopId, uint groupId, bool isAttacker) { }