private void InterConferenceFixtures(Dictionary <string, string> teamRankings, int nextSeason) { GameDocument game = _gameService.Get(); for (int i = 0; i < interConfWeeks.Length; i++) { if (i < 5) { // NorthEast vs SouthEast & NorthWest vs SouthWest foreach (var division in game.Divisions) { var teamAKey = "North" + division + IntraConfAteams[i]; var teamBKey = "South" + division + IntraConfBteams[i]; CreateFixture(nextSeason, interConfWeeks[i], "INTER-CONFERENCE", teamRankings[teamAKey], teamRankings[teamBKey]); } } else { //NorthEast vs SouthWest & NorthWest vs SouthEast var teamA1Key = "North" + "East" + IntraConfAteams[i]; var teamB1Key = "South" + "West" + IntraConfBteams[i]; CreateFixture(nextSeason, interConfWeeks[i], "INTER-CONFERENCE", teamRankings[teamA1Key], teamRankings[teamB1Key]); var teamA2Key = "North" + "West" + IntraConfAteams[i]; var teamB2Key = "South" + "East" + IntraConfBteams[i]; CreateFixture(nextSeason, interConfWeeks[i], "INTER-CONFERENCE", teamRankings[teamA2Key], teamRankings[teamB2Key]); } } }
private Dictionary <string, string> GetDivisionalRankings() { GameDocument game = _gameService.Get(); Dictionary <string, string> teamRankings = new Dictionary <string, string>(); foreach (var conference in game.Conferences) { foreach (var division in game.Divisions) { int rank = 1; List <StandingsDocument> teams = _standingsService.GetDivisionStandings(conference, division, game.Season); foreach (var team in teams) { var keyString = conference + division + rank.ToString(); teamRankings.Add(keyString, team.TeamId); rank++; } } } return(teamRankings); }
protected override bool ConfirmClose(IDocument document) { GameDocument gameDcument = document as GameDocument; if (gameDcument == null) { return(base.ConfirmClose(document)); } bool closeConfirmed = true; if (gameDcument.AnyDirty) { string message = "One or more level and/or external resource is dirty" + Environment.NewLine + "Save Changes?"; FileDialogResult result = FileDialogService.ConfirmFileClose(message); if (result == FileDialogResult.Yes) { closeConfirmed = Save(document); } else if (result == FileDialogResult.Cancel) { closeConfirmed = false; } } return(closeConfirmed); }
public override void Decode(ByteStream stream) { if (this.Success) { this.Document = CouchbaseDocument.Decode <GameDocument>(stream); } }
private void UpdateFinalsFixtures() { GameDocument game = _gameService.Get(); foreach (var conference in game.Conferences) { int scheduleStrength = 0; string homeTeam = ""; string awayTeam = ""; foreach (var division in game.Divisions) { var leader = _standingsService.GetDivisionLeaders(conference, division, game.Season); Console.WriteLine("Conference = " + conference); Console.WriteLine("Division = " + division); Console.WriteLine("leader = " + leader.TeamId); if (leader.ScheduleWeight >= scheduleStrength) { awayTeam = homeTeam; homeTeam = leader.TeamId; scheduleStrength = leader.ScheduleWeight; } else { awayTeam = leader.TeamId; } } Console.WriteLine("homeTeam = " + homeTeam); Console.WriteLine("awayTeam = " + awayTeam); _fixturesService.UpdateFinals(game.Season, conference, homeTeam, awayTeam); } }
public void PlayWeek() { GameDocument game = _gameService.Get(); if (game.NextWeekType == WeekType.RegularSeason) { List <FixturesDocument> fixtures = _fixturesService.GetThisWeeksFixtures(game.Season, game.Week); foreach (var fixture in fixtures) { PlayGame(fixture.Id); UpdateResult(fixture.Id, game.Season); } UpdateDivisionRankings(); UpdateScheduleStrength(); } var nextWeek = game.Week + 1; var nextWeekGameType = game.NextWeekType; if (nextWeek > RegularSeasonLength) { UpdateFinalsFixtures(); nextWeekGameType = WeekType.DivisionalFinals; } _gameService.NewWeek(nextWeek, nextWeekGameType); }
public static GameObjectReference Create(DomNode node) { if (node == null) { throw new ArgumentNullException("node"); } if (!node.Is <IGameObject>()) { throw new ArgumentException(node.Type.Name + " is not derived from " + Schema.gameObjectType.Type.Name); } GameDocument gameDoc = node.GetRoot().As <GameDocument>(); if (gameDoc == null) { throw new ArgumentException("node must belong to a document."); } // create game object reference. DomNode refNode = new DomNode(Schema.gameObjectReferenceType.Type); GameObjectReference gobRef = refNode.As <GameObjectReference>(); gobRef.SetTarget(node); gobRef.UpdateUri(); return(gobRef); }
/// <summary> /// Resolves the Uri to a Dom object using the parent's collection's resolvers</summary> /// <returns>Dom object, referenced by the Uri, or null if uri can't be resolved</returns> public void Resolve() { if (m_target == null) { var gameDocRegistry = Globals.MEFContainer.GetExportedValue <GameDocumentRegistry>(); Uri ur = Uri; if (ur == null) { m_error = "ref attribute is null"; } else if (!File.Exists(ur.LocalPath)) { m_error = "File not found: " + ur.LocalPath; } else if (gameDocRegistry.FindDocument(ur) != null) { m_error = "Causes circular ref: " + ur.LocalPath; } else { SchemaLoader schemaloader = Globals.MEFContainer.GetExportedValue <SchemaLoader>(); GameDocument gameDoc = GameDocument.OpenOrCreate(ur, schemaloader); m_target = gameDoc.As <IGame>(); ((Game)m_target).SetParent(this); } } }
public static GameObjectReference Create(DomNode node) { if (node == null) { throw new ArgumentNullException("node"); } if (!node.Is <IGameObject>()) { throw new ArgumentException(node.Type.Name + " is not derived from " + Schema.gameObjectType.Type.Name); } DomNode rootNode = node.GetRoot(); GameDocument gameDoc = rootNode.As <GameDocument>(); if (gameDoc == null) { throw new ArgumentException("nod must belong to a document."); } // create game object reference. DomNode refNode = new DomNode(Schema.gameObjectReferenceType.Type); GameObjectReference gobRef = refNode.As <GameObjectReference>(); // Create Uri Uri ur = new Uri(gameDoc.Uri + "#" + node.GetId()); refNode.SetAttribute(Schema.gameObjectReferenceType.refAttribute, ur); gobRef.m_target = node; return(gobRef); }
public static GameDto AsDto(this GameDocument game) => new GameDto { Id = game.Id, Name = game.Name, Waypoints = game.Places.ToList(), QuestionId = game.QuestionId.ToList() };
/// <summary> /// Checks whether the client can do the command, if it handles it</summary> /// <param name="commandTag">Command to be done</param> /// <returns>True iff client can do the command</returns> public override bool CanDoCommand(object commandTag) { bool result = base.CanDoCommand(commandTag); if (result == false && StandardCommand.FileSave.Equals(commandTag)) { GameDocument gamedoc = DocumentRegistry.ActiveDocument.As <GameDocument>(); result = gamedoc != null ? gamedoc.AnyDirty : result; } return(result); }
/// <summary> /// restoring state of the game from a file /// </summary> private void loadGameToolStripMenuItem_Click(object sender, EventArgs e) { using (Stream stream = File.Open("mydata.bin", FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter(); GDocument = (GameDocument)bin.Deserialize(stream); Shapes.Clear(); Shapes = GDocument.Shapes; intersection = GDocument.Intersection; level = Shapes.Count() / 2; } Refresh(); }
private void IntraConferenceFixtures(Dictionary <string, string> teamRankings, int nextSeason) { GameDocument game = _gameService.Get(); for (int i = 0; i < intraConfWeeks.Length; i++) { foreach (var conference in game.Conferences) { var teamAKey = conference + "East" + IntraConfAteams[i]; var teamBKey = conference + "West" + IntraConfBteams[i]; CreateFixture(nextSeason, intraConfWeeks[i], "INTRA-CONFERENCE", teamRankings[teamAKey], teamRankings[teamBKey]); } } }
public void SetUpNewSeason() { GameDocument game = _gameService.Get(); var nextSeason = game.Season + 1; Dictionary <string, string> teamRankings = GetDivisionalRankings(); DivisionalFixtures(teamRankings, nextSeason); IntraConferenceFixtures(teamRankings, nextSeason); InterConferenceFixtures(teamRankings, nextSeason); ConferenceFinals(teamRankings, nextSeason); CreateStandingsForNewSeason(nextSeason); _gameService.NewSeason(nextSeason); }
private void DivisionalFixtures(Dictionary <string, string> teamRankings, int nextSeason) { GameDocument game = _gameService.Get(); for (int i = 0; i < divWeeks.Length; i++) { foreach (var conference in game.Conferences) { foreach (var division in game.Divisions) { var teamAKey = conference + division + divAteams[i]; var teamBKey = conference + division + divBteams[i]; CreateFixture(nextSeason, divWeeks[i], "DIVISION", teamRankings[teamAKey], teamRankings[teamBKey]); } } } }
private void UpdateUri() { GameDocument gameDoc = m_target.GetRoot().As <GameDocument>(); if (gameDoc != null) { Uri ur = new Uri(gameDoc.Uri + "#" + m_target.GetId()); // Note: Must set property to null before setting the new uri. // Reason: The old and new uri might only differ by the fragment sections. // Fragment is what comes after "#" symbol. // DomNode.SetAttribute(...) considers two URIs to be equal event if // the fragment parts are different. SetAttribute(Schema.gameObjectReferenceType.refAttribute, null); SetAttribute(Schema.gameObjectReferenceType.refAttribute, ur); } }
public static GameReference CreateNew(GameDocument subDoc) { if (subDoc == null) { throw new ArgumentNullException("subDoc"); } string fileName = System.IO.Path.GetFileName(subDoc.Uri.LocalPath); DomNode gameRefNode = new DomNode(Schema.gameReferenceType.Type); gameRefNode.SetAttribute(Schema.gameReferenceType.nameAttribute, fileName); gameRefNode.SetAttribute(Schema.gameReferenceType.refAttribute, subDoc.Uri); GameReference gameRef = gameRefNode.As <GameReference>(); gameRef.m_target = subDoc.Cast <IGame>(); subDoc.Cast <Game>().SetParent(gameRef); gameRef.m_error = string.Empty; return(gameRef); }
public void PlayChampionship() { GameDocument game = _gameService.Get(); if (game.NextWeekType == WeekType.Championship) { List <FixturesDocument> fixtures = _fixturesService.GetThisWeeksFixtures(game.Season, game.Week); foreach (var fixture in fixtures) { PlayGame(fixture.Id); } } var nextWeek = game.Week + 1; var nextWeekGameType = WeekType.EndSeason; _gameService.NewWeek(nextWeek, nextWeekGameType); }
private void UpdateChampionshipFixture() { GameDocument game = _gameService.Get(); var winners = new Dictionary <string, string>(); foreach (var conference in game.Conferences) { var fixture = _fixturesService.GetFinalsFixtures(game.Season, conference); if (fixture.HomeScore > fixture.AwayScore) { winners.Add(conference, fixture.HomeTeamId); } else { winners.Add(conference, fixture.AwayTeamId); } } var scheduleStrength = 0; string homeTeam = ""; string awayTeam = ""; foreach (var conference in game.Conferences) { winners.TryGetValue(conference, out string finalist); var leader = _standingsService.GetTeamStandings(finalist, game.Season); if (leader.ScheduleWeight >= scheduleStrength) { awayTeam = homeTeam; homeTeam = leader.TeamId; scheduleStrength = leader.ScheduleWeight; } else { awayTeam = leader.TeamId; } } _fixturesService.UpdateChampionship(game.Season, homeTeam, awayTeam); }
/// <summary> /// Saves the document under its current name</summary> /// <param name="document">Document to save</param> /// <returns>true, if document was successfully saved and false if the user cancelled /// or there was some kind of problem</returns> /// <remarks>All exceptions are caught and are reported via OnSaveException(). The /// IDocumentClient is responsible for the save operation and ensuring that any /// existing files are not corrupted if the save fails. Only Documents that are dirty /// are really saved.</remarks> public override bool Save(IDocument document) { GameDocument gameDcument = document as GameDocument; if (gameDcument == null) { return(base.Save(document)); } if (IsUntitled(document)) { return(SaveAs(document)); } if (!gameDcument.AnyDirty) { return(true); } return(SafeSave(document, DocumentEventType.Saved)); }
private void UpdateDivisionRankings() { GameDocument game = _gameService.Get(); foreach (var conference in game.Conferences) { foreach (var division in game.Divisions) { var divisionStandings = _standingsService.GetDivisionStandings(conference, division, game.Season); var newDivisionRank = divisionStandings.OrderByDescending(o => o.OverallPct) .ThenByDescending(o => o.DivisionPct) .ThenByDescending(o => o.ConferencePct) .ThenByDescending(o => (o.OverallPointsFor - o.OverallPointsAgainst)).ToList(); var rank = 1; foreach (var record in newDivisionRank) { _standingsService.UpdateDivisionRank(record.Id, rank); rank++; } } } }
/// <summary> /// Saves the document under its current name</summary> /// <param name="document">Document to save</param> /// <returns>true, if document was successfully saved and false if the user cancelled /// or there was some kind of problem</returns> /// <remarks>All exceptions are caught and are reported via OnSaveException(). The /// IDocumentClient is responsible for the save operation and ensuring that any /// existing files are not corrupted if the save fails. Only Documents that are dirty /// are really saved.</remarks> public override bool Save(IDocument document) { GameDocument gameDcument = document as GameDocument; if (gameDcument == null) { return(base.Save(document)); } if (IsUntitled(document)) { return(SaveAs(document)); } if (!m_gameDocumentRegistry.AnyDocumentDirty && !m_gameDocumentRegistry.AnyEditableResourceOwnerDirty) { return(true); } return(SafeSave(document, DocumentEventType.Saved)); }
protected override bool ConfirmClose(IDocument document) { // <<XLE if (!LevelEditorXLE.Patches.ConfirmClose(document, FileDialogService)) { return(false); } // XLE>> GameDocument gameDcument = document as GameDocument; if (gameDcument == null) { return(base.ConfirmClose(document)); } bool closeConfirmed = true; if (m_gameDocumentRegistry.AnyDocumentDirty || m_gameDocumentRegistry.AnyEditableResourceOwnerDirty) { string message = "One or more level and/or external resource is dirty" + Environment.NewLine + "Save Changes?"; FileDialogResult result = FileDialogService.ConfirmFileClose(message); if (result == FileDialogResult.Yes) { closeConfirmed = Save(document); } else if (result == FileDialogResult.Cancel) { closeConfirmed = false; } } return(closeConfirmed); }
public async Task <JObject> Get(long id, [FromQuery(Name = "pass")] string passToken) { Task <AccountDocument> taskAccount = UserManager.GetAccount(id); Task <GameDocument> taskDocument = UserManager.GetAvatar(id); AccountDocument accountDocument = await taskAccount; GameDocument gameDocument = await taskDocument; if (accountDocument == null || gameDocument == null) { return(this.BuildResponse(HttpStatusCode.InternalServerError)); } if (this.GetUserRole() <= UserRole.NULL && passToken != accountDocument.PassToken) { return(this.BuildResponse(HttpStatusCode.Forbidden)); } bool online = await ServerAdmin.SessionDatabase.Exists(id); JObject response = this.BuildResponse(HttpStatusCode.OK).AddAttribute("online", online); JObject accountObj = new JObject(); if (this.GetUserRole() >= UserRole.MODERATOR) { accountObj.Add("id", (long)accountDocument.Id); accountObj.Add("passToken", accountDocument.PassToken); } accountObj.Add("status", accountDocument.State.ToString()); if (accountDocument.StateArg != null) { switch (accountDocument.State) { case AccountState.BANNED: accountObj.Add("reason", accountDocument.StateArg); break; case AccountState.LOCKED: accountObj.Add("unlockCode", accountDocument.StateArg); break; } } accountObj.Add("rank", accountDocument.Rank.ToString()); accountObj.Add("country", accountDocument.Country); accountObj.Add("createTime", TimeUtil.GetDateTimeFromTimestamp(accountDocument.CreateTime).ToString("F")); accountObj.Add("lastSessionTime", TimeUtil.GetDateTimeFromTimestamp(accountDocument.LastSessionTime).ToString("F")); accountObj.Add("playTimeSecs", UserController.GetSecondsToTime(accountDocument.PlayTimeSeconds)); response.Add("account", accountObj); JObject avatarObj = new JObject(); avatarObj.Add("name", gameDocument.LogicClientAvatar.GetName()); avatarObj.Add("nameChanged", gameDocument.LogicClientAvatar.GetNameChangeState() >= 1); avatarObj.Add("diamonds", gameDocument.LogicClientAvatar.GetDiamonds()); avatarObj.Add("lvl", gameDocument.LogicClientAvatar.GetExpLevel()); response.Add("avatar", avatarObj); if (gameDocument.LogicClientAvatar.IsInAlliance()) { JObject allianceObj = new JObject(); allianceObj.Add("name", gameDocument.LogicClientAvatar.GetAllianceName()); allianceObj.Add("badgeId", gameDocument.LogicClientAvatar.GetAllianceBadgeId()); allianceObj.Add("lvl", gameDocument.LogicClientAvatar.GetAllianceLevel()); switch (gameDocument.LogicClientAvatar.GetAllianceRole()) { case LogicAvatarAllianceRole.MEMBER: allianceObj.Add("role", "Member"); break; case LogicAvatarAllianceRole.ELDER: allianceObj.Add("role", "Elder"); break; case LogicAvatarAllianceRole.LEADER: allianceObj.Add("role", "Leader"); break; case LogicAvatarAllianceRole.CO_LEADER: allianceObj.Add("role", "Co Leader"); break; } response.Add("alliance", allianceObj); } if (online) { JArray opCommandArray = new JArray(); opCommandArray.Add((int)OpCommandType.RESET_ACCOUNT); opCommandArray.Add((int)OpCommandType.LOAD_PRESET_VILLAGE); opCommandArray.Add((int)OpCommandType.ATTACK_GENERATED_VILLAGE); opCommandArray.Add((int)OpCommandType.ATTACK_RANDOM_VILLAGE); opCommandArray.Add((int)OpCommandType.ATTACK_MY_VILLAGE); response.Add("op-cmd", opCommandArray); JArray debugCommandArray = new JArray(); if (this.GetUserRole() >= UserRole.TESTER) { debugCommandArray.Add((int)DebugCommandType.FAST_FORWARD_1_MIN); debugCommandArray.Add((int)DebugCommandType.FAST_FORWARD_1_HOUR); debugCommandArray.Add((int)DebugCommandType.FAST_FORWARD_24_HOUR); debugCommandArray.Add((int)DebugCommandType.LOCK_CLAN_CASTLE); debugCommandArray.Add((int)DebugCommandType.CAUSE_DAMAGE); debugCommandArray.Add((int)DebugCommandType.TOGGLE_INVULNERABILITY); debugCommandArray.Add((int)DebugCommandType.TRAVEL); debugCommandArray.Add((int)DebugCommandType.TOGGLE_RED); debugCommandArray.Add((int)DebugCommandType.ADD_UNIT); debugCommandArray.Add((int)DebugCommandType.ADD_UNITS); debugCommandArray.Add((int)DebugCommandType.ADD_PRESET_TROOPS); debugCommandArray.Add((int)DebugCommandType.ADD_ALLIANCE_UNITS); debugCommandArray.Add((int)DebugCommandType.DEPLOY_ALL_TROOPS); debugCommandArray.Add((int)DebugCommandType.REMOVE_UNITS); debugCommandArray.Add((int)DebugCommandType.INCREASE_HERO_LEVELS); debugCommandArray.Add((int)DebugCommandType.RESET_HERO_LEVELS); debugCommandArray.Add((int)DebugCommandType.SET_MAX_UNIT_SPELL_LEVELS); debugCommandArray.Add((int)DebugCommandType.SET_MAX_HERO_LEVELS); debugCommandArray.Add((int)DebugCommandType.COMPLETE_TUTORIAL); debugCommandArray.Add((int)DebugCommandType.COMPLETE_HOME_TUTORIALS); debugCommandArray.Add((int)DebugCommandType.COMPLETE_WAR_TUTORIAL); debugCommandArray.Add((int)DebugCommandType.RESET_ALL_TUTORIALS); debugCommandArray.Add((int)DebugCommandType.RESET_WAR_TUTORIAL); debugCommandArray.Add((int)DebugCommandType.SHIELD_TO_HALF); debugCommandArray.Add((int)DebugCommandType.INCREASE_TROPHIES); debugCommandArray.Add((int)DebugCommandType.DECREASE_TROPHIES); debugCommandArray.Add((int)DebugCommandType.ADD_100_TROPHIES); debugCommandArray.Add((int)DebugCommandType.REMOVE_100_TROPHIES); debugCommandArray.Add((int)DebugCommandType.ADD_1000_TROPHIES); debugCommandArray.Add((int)DebugCommandType.REMOVE_1000_TROPHIES); debugCommandArray.Add((int)DebugCommandType.SET_RANDOM_TROPHIES); debugCommandArray.Add((int)DebugCommandType.INCREASE_XP_LEVEL); debugCommandArray.Add((int)DebugCommandType.RANDOM_RESOURCES_TROPHY_XP); debugCommandArray.Add((int)DebugCommandType.ADD_1000_CLAN_XP); debugCommandArray.Add((int)DebugCommandType.RANDOM_ALLIANCE_EXP_LEVEL); } debugCommandArray.Add((int)DebugCommandType.ADD_GEMS); debugCommandArray.Add((int)DebugCommandType.ADD_RESOURCES); debugCommandArray.Add((int)DebugCommandType.ADD_WAR_RESOURCES); debugCommandArray.Add((int)DebugCommandType.REMOVE_RESOURCES); debugCommandArray.Add((int)DebugCommandType.REMOVE_WAR_RESOURCES); debugCommandArray.Add((int)DebugCommandType.COLLECT_WAR_RESOURCES); debugCommandArray.Add((int)DebugCommandType.UNLOCK_MAP); debugCommandArray.Add((int)DebugCommandType.RESET_MAP_PROGRESS); debugCommandArray.Add((int)DebugCommandType.PAUSE_ALL_BOOSTS); debugCommandArray.Add((int)DebugCommandType.GIVE_REENGAGEMENT_LOOT_FOR_30_DAYS); debugCommandArray.Add((int)DebugCommandType.UPGRADE_ALL_BUILDINGS); debugCommandArray.Add((int)DebugCommandType.UPGRADE_TO_MAX_FOR_TH); debugCommandArray.Add((int)DebugCommandType.REMOVE_OBSTACLES); debugCommandArray.Add((int)DebugCommandType.DISARM_TRAPS); debugCommandArray.Add((int)DebugCommandType.REMOVE_ALL_AMMO); debugCommandArray.Add((int)DebugCommandType.RESET_ALL_LAYOUTS); debugCommandArray.Add((int)DebugCommandType.LOAD_LEVEL); response.Add("debug-cmd", debugCommandArray); } if (this.GetUserRole() >= UserRole.MODERATOR) { JArray administrationCommandArray = new JArray(); switch (accountDocument.State) { case AccountState.NORMAL: administrationCommandArray.Add((int)AdminCommandType.BAN_ACCOUNT); administrationCommandArray.Add((int)AdminCommandType.LOCK_ACCOUNT); break; case AccountState.LOCKED: administrationCommandArray.Add((int)AdminCommandType.UNLOCK_ACCOUNT); break; case AccountState.BANNED: administrationCommandArray.Add((int)AdminCommandType.UNBAN_ACCOUNT); break; } administrationCommandArray.Add((int)AdminCommandType.CHANGE_RANK); if (online) { administrationCommandArray.Add((int)AdminCommandType.DISCONNECT); } response.Add("administration-cmd", administrationCommandArray); } return(response); }
private static void OnGameStartFakeAttackMessageReceived(GameStartFakeAttackMessage message) { if (GameSessionManager.TryGet(message.SessionId, out GameSession session)) { if (message.AccountId != null) { ServerRequestManager.Create(new GameAvatarRequestMessage { AccountId = message.AccountId }, ServerManager.GetDocumentSocket(9, message.AccountId)).OnComplete = args => { if (session.IsDestructed()) { return; } if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success) { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { GameAvatarResponseMessage gameAvatarResponseMessage = (GameAvatarResponseMessage)args.ResponseMessage; GameDocument document = gameAvatarResponseMessage.Document; AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = document.LogicClientHome, HomeOwnerAvatar = document.LogicClientAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = document.SaveTime, MaintenanceTime = document.MaintenanceTime }; } } else { AttackHomeFailedMessage attackHomeFailedMessage = new AttackHomeFailedMessage(); attackHomeFailedMessage.SetReason(AttackHomeFailedMessage.Reason.GENERIC); session.SendPiranhaMessage(attackHomeFailedMessage, 1); } }; } else { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = GameBaseGenerator.GenerateBase((LogicGameObjectData)message.ArgData), HomeOwnerAvatar = GameBaseGenerator.HomeOwnerAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = TimeUtil.GetTimestamp(), MaintenanceTime = -1 }; } } } }