private void Request(SocketCommandContext Context, dynamic target, string name) { //Check if the user has a town or nation. NationAccount nationAccount = new NationAccount("", Context.Message.Author.Id); if (DatabaseService.CheckExistance(nationAccount) == DatabaseService.NationExistance.LeaderAlreadyHasNation) { Request2(Context, nationAccount, target, name); } else { //Check if they're a town. TownAccount townAccount = new TownAccount("", Context.Message.Author.Id); if (DatabaseService.CheckExistance(townAccount) == DatabaseService.TownExistance.LeaderAlreadyHasTown) { Request2(Context, townAccount, target, name); } else { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync("You do not have a town or nation. Create a town by doing `-town register`."); return; } } }
public Task RemoveAlly(string name = null) { if (name == null) { return(ReplyAsync("Please also enter a name.")); } //Check if they're a nation. NationAccount nationAccount = new NationAccount(name, 0); if (DatabaseService.CheckExistance(nationAccount) == DatabaseService.NationExistance.NameInUse) { Remove(Context, nationAccount, name); } else { //Check if they're a town. TownAccount townAccount = new TownAccount(name, 0); if (DatabaseService.CheckExistance(townAccount) == DatabaseService.TownExistance.NameInUse) { Remove(Context, townAccount, name); } else { Context.Message.AddReactionAsync(new Emoji("❎")); return(ReplyAsync("That nation or town couldn't be found.")); } } return(Task.CompletedTask); }
void OnNationAccountListener(string path, INodeData data) { int rTs = 0; NationAccount account = data as NationAccount; if (account.TeamDataUpdated) { account.TeamDataUpdated = false; for (int i = 0; i < TeamItems.Length; ++i) { TeamItems[i].Fill(account.TeamList[i]); TeamItems[i].ctrl = this; eTeamState state = account.TeamList[i].RealState; if (state == eTeamState.Available || state == eTeamState.InTheWar) { //非复活状态 ReviveButton.gameObject.CustomSetActive(false); TimeButton.gameObject.CustomSetActive(false); isAllTeamDeath = false; } } if (!isAllTeamDeath) { return; } for (int i = 0; i < TeamItems.Length; i++) { TeamItems[i].OffBtn.gameObject.CustomSetActive(false); TeamItems[i].GoOnButton.gameObject.CustomSetActive(false); TeamItems[i].Mask.gameObject.CustomSetActive(true); if (TeamItems[i].TeamData.ReviveTs != -2) { rTs = TeamItems[i].TeamData.ReviveTs; } } ReviveButton.gameObject.CustomSetActive(true); TimeButton.gameObject.CustomSetActive(true); LTUIUtil.SetText(ReviveCostLabel, NationManager.Instance.Config.TeamReviveCost.ToString()); if (BalanceResourceUtil.GetUserDiamond() < NationManager.Instance.Config.TeamReviveCost) { ReviveCostLabel.color = LT.Hotfix.Utility.ColorUtility.RedColor; } else { ReviveCostLabel.color = LT.Hotfix.Utility.ColorUtility.WhiteColor; } if (ReviveCoroutine != null) { StopCoroutine(ReviveCoroutine); } if (controller.gameObject.activeSelf) { ReviveCoroutine = StartCoroutine(ReviveTimer(rTs)); } } }
void OnNationAccountListener(string path, INodeData data) { NationAccount account = data as NationAccount; if (account.TeamDataUpdated) { account.TeamDataUpdated = false; SetTeamState(); } }
public NationExistance CheckExistance(NationAccount account) { ValueRange values = GetValues("nations"); foreach (IList <object> row in values.Values.Skip(1)) { if (row[2].ToString() == account.LeaderID) { return(NationExistance.LeaderAlreadyHasNation); } if (row[1].ToString() == account.Name) { return(NationExistance.NameInUse); } } return(NationExistance.DoesntExist); }
public Task RegisterNation(string name = null) { if (name == null) { return(ReplyAsync("Please also specify a nation name.")); } UserAccount userAccount = new UserAccount(Context.Message.Author.Id, Context.Message.Author.ToString()); if (DatabaseService.CheckExistance(userAccount) == DatabaseService.UserExistance.DoesntExist) { Context.Message.AddReactionAsync(new Emoji("❎")); return(ReplyAsync("Please create an account first by using `-register`.")); } NationAccount account = new NationAccount(name, Context.Message.Author.Id); TownAccount town = DatabaseService.GetTownByLeaderID(Context.Message.Author.Id.ToString()); town.NationID = account.ID; DatabaseService.UpdateEntry(town); var response = DatabaseService.CheckExistance(account); if (response == DatabaseService.NationExistance.DoesntExist) { DatabaseService.AddEntry(account); Context.Message.AddReactionAsync(new Emoji("✅")); return(ReplyAsync("Your nation has been registered. Use `-nation` to access your nation.")); } else if (response == DatabaseService.NationExistance.LeaderAlreadyHasNation) { Context.Message.AddReactionAsync(new Emoji("❎")); return(ReplyAsync("You already have a nation registered. Use `-nation` to access your nation.")); } else if (response == DatabaseService.NationExistance.NameInUse) { Context.Message.AddReactionAsync(new Emoji("❎")); return(ReplyAsync("That name is already in use, try a different name.")); } return(Task.CompletedTask); }
private void OnNationAccount(string path, INodeData data) { NationAccount account = NationManager.Instance.Account; // data as NationAccount; IsShowChannelNation = !string.IsNullOrEmpty(account.NationName); }
public void UpdateEntry(NationAccount account) { UpdateEntry("nations", account.List); }
public void AddEntry(NationAccount account) { AddEntry("nations", account.List); }
private void Request2(SocketCommandContext Context, dynamic user, dynamic target, string name) { string aID = ""; string bID = ""; string aDiscordID = ""; string bDiscordID = ""; string nameA = ""; string nameB = ""; if (user.GetType() == typeof(TownAccount)) { TownAccount town = DatabaseService.GetTownByLeaderID(Context.Message.Author.Id.ToString()); aID = town.ID; nameA = $"the city of {town.Name}"; aDiscordID = town.LeaderID; } else { var nation = DatabaseService.GetNationByLeaderID(Context.Message.Author.Id.ToString()); aID = nation.ID; nameA = $"the nation of {nation.Name}"; aDiscordID = nation.LeaderID; } if (target.GetType() == typeof(TownAccount)) { TownAccount town = DatabaseService.GetTownByName(name); bID = town.ID; nameB = $"the city of {town.Name}"; bDiscordID = town.LeaderID; } else { NationAccount nation = DatabaseService.GetNationByName(name); bID = nation.ID; nameB = $"the nation of {nation.Name}"; bDiscordID = nation.LeaderID; } AllyEntry ally = new AllyEntry(aID, bID, aDiscordID, bDiscordID, nameA, nameB); //Check if the alliance is already pending. if (DatabaseService.CheckExistancePending(ally)) { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync($"You already have a pending alliance request with *`{name}`*."); return; } //Check if the alliance already exists. if (DatabaseService.CheckExistance(ally)) { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync($"You already have an alliance with *`{name}`*."); return; } if (aID == bID) { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync($"You're already allied with yourself."); return; } Context.Client.GetUser(ulong.Parse(bDiscordID)).GetOrCreateDMChannelAsync().Result.SendMessageAsync($@"***New alliance request*** *Greetings,* *`{FirstLetterToUpper(nameA)}`* has requested an alliance with *`{nameB}`*. Please reply with `-accept {ally.ID}` or `-deny {ally.ID}`."); DatabaseService.AddEntryPending(ally); Context.Message.AddReactionAsync(new Emoji("✅")); ReplyAsync($"The alliance request has been sent to *`{name}`*. I will get back to you with their reaction."); }
private void Remove2(SocketCommandContext Context, dynamic user, dynamic target, string name) { string aID = ""; string bID = ""; string aDiscordID = ""; string bDiscordID = ""; string nameA = ""; string nameB = ""; if (user.GetType() == typeof(TownAccount)) { TownAccount town = DatabaseService.GetTownByLeaderID(Context.Message.Author.Id.ToString()); aID = town.ID; nameA = $"the city of {town.Name}"; aDiscordID = town.LeaderID; } else { var nation = DatabaseService.GetNationByLeaderID(Context.Message.Author.Id.ToString()); aID = nation.ID; nameA = $"the nation of {nation.Name}"; aDiscordID = nation.LeaderID; } if (target.GetType() == typeof(TownAccount)) { TownAccount town = DatabaseService.GetTownByName(name); bID = town.ID; nameB = $"the city of {town.Name}"; bDiscordID = town.LeaderID; } else { NationAccount nation = DatabaseService.GetNationByName(name); bID = nation.ID; nameB = $"the nation of {nation.Name}"; bDiscordID = nation.LeaderID; } AllyEntry entry = new AllyEntry(aID, bID, aDiscordID, bDiscordID, nameA, nameB); //Check if the alliance exists. if (!DatabaseService.CheckExistance(entry)) { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync($"You do not have an alliance with *`{name}`*."); return; } entry = DatabaseService.GetAlliance(aID, bID); if (aID == bID) { Context.Message.AddReactionAsync(new Emoji("❎")); ReplyAsync($"You can't betray yourself."); return; } Context.Client.GetUser(ulong.Parse(bDiscordID)).GetOrCreateDMChannelAsync().Result.SendMessageAsync($@"***Alliance terminated*** *Greetings,* *`{FirstLetterToUpper(nameA)}`* has hereby terminated the alliance with *`{nameB}`*. Please accept our condolences. "); DatabaseService.AddEntry(entry); DatabaseService.AddEntry(new AllyEntry(entry.BPartyID, entry.APartyID, entry.BPartyDiscordID, entry.APartyDiscordID, entry.BPartyName, entry.APartyName)); Context.Message.AddReactionAsync(new Emoji("✅")); ReplyAsync($"The alliance with *`{name}`* has been terminated. I have informed them as well."); }