public void SaveLoadDoesNotMaintainsReferencesForNonPartyMemberCastedBuffs() { Party party = new Party(); Character dummy = CharacterList.TestEnemy(); Character buffCaster = CharacterList.TestEnemy(); Character buffRecipient = CharacterList.TestEnemy(); Poison poison = new Poison(); Debug.Log("BuffcasterID: " + buffCaster.Id); poison.Caster = new BuffParams(buffCaster.Stats, buffCaster.Id); buffRecipient.Buffs.AddBuff(poison); party.AddMember(dummy); party.AddMember(CharacterList.TestEnemy()); party.AddMember(buffRecipient); PartySave retrieved = FromJson <PartySave>(ToJson(party.GetSaveObject())); Party party2 = new Party(); party2.InitFromSaveObject(retrieved); List <Character> a = party.ToList(); List <Character> b = party.ToList(); Character caster = b[1]; Character target = b[2]; Assert.IsTrue(party.Equals(party2)); Assert.AreEqual(party, party2); Assert.AreNotSame(party.Collection.ToList()[1].Stats, party.Collection.ToList()[2].Buffs.ToList()[0].BuffCaster); }
public void SaveLoadMaintainsEquipmentBonusesForNonPartyMemberCastedBuffs() { Party party = new Party(); Character dummy = CharacterList.TestEnemy(); Character buffCaster = CharacterList.TestEnemy(); buffCaster.Inventory.ForceAdd(new BrokenSword()); buffCaster.Equipment.AddEquip(buffCaster.Inventory, new BuffParams(buffCaster.Stats, buffCaster.Id), new BrokenSword()); Character buffRecipient = CharacterList.TestEnemy(); StrengthScalingPoison poison = new StrengthScalingPoison(); Debug.Log("BuffcasterID: " + buffCaster.Id); poison.Caster = new BuffParams(buffCaster.Stats, buffCaster.Id); buffRecipient.Buffs.AddBuff(poison); party.AddMember(dummy); party.AddMember(CharacterList.TestEnemy()); party.AddMember(buffRecipient); PartySave retrieved = FromJson <PartySave>(ToJson(party.GetSaveObject())); Party party2 = new Party(); party2.InitFromSaveObject(retrieved); int spoofedStrength = party2.Collection.ToArray()[2].Buffs.ToArray()[0].BuffCaster.GetEquipmentBonus(StatType.STRENGTH); Assert.AreEqual(spoofedStrength, (new BrokenSword()).Stats[StatType.STRENGTH]); Debug.Log("" + spoofedStrength); }
public void SaveLoadMaintainsBonusesFromEquipmentAndBuffsForPartyMemberCastedBuffs() { Party party = new Party(); Character dummy = CharacterList.TestEnemy(); Character buffCaster = CharacterList.TestEnemy(); buffCaster.Inventory.ForceAdd(new BrokenSword()); buffCaster.Equipment.AddEquip(buffCaster.Inventory, new BuffParams(buffCaster.Stats, buffCaster.Id), new BrokenSword()); buffCaster.AddBuff(new StrengthBoost()); Character buffRecipient = CharacterList.TestEnemy(); StrengthScalingPoison poison = new StrengthScalingPoison(); Debug.Log("BuffcasterID: " + buffCaster.Id); poison.Caster = new BuffParams(buffCaster.Stats, buffCaster.Id); buffRecipient.Buffs.AddBuff(poison); party.AddMember(dummy); party.AddMember(CharacterList.TestEnemy()); party.AddMember(buffRecipient); party.AddMember(buffCaster); PartySave retrieved = FromJson <PartySave>(ToJson(party.GetSaveObject())); Party party2 = new Party(); party2.InitFromSaveObject(retrieved); Assert.AreEqual(buffCaster.Stats, party2.Collection.ToArray()[3].Stats); Assert.AreEqual(buffCaster.Buffs, party2.Collection.ToArray()[3].Buffs); }
private static void JoinParty(GameSession session, PartyNotice response, int partyId) { Party party = GameServer.PartyManager.GetPartyById(partyId); if (party == null) { session.Send(PartyPacket.Notice(session.Player, PartyNotice.PartyNotFound)); return; } if (party.Members.Contains(session.Player) || party.Leader == session.Player) { return; } if (response != PartyNotice.AcceptedInvite) { party.Leader.Session.Send(PartyPacket.Notice(session.Player, response)); return; } if (party.Members.Count >= 10) { session.Send(PartyPacket.Notice(session.Player, PartyNotice.FullParty)); return; } if (session.Player.Party != null) { Party currentParty = session.Player.Party; if (currentParty.Members.Count == 1) { currentParty.RemoveMember(session.Player); } } if (party.Members.Count == 1) { //establish party. party.BroadcastPacketParty(PartyPacket.Join(session.Player)); party.AddMember(session.Player); session.Send(PartyPacket.Create(party, true)); party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(party.Leader)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player)); return; } party.BroadcastPacketParty(PartyPacket.Join(session.Player)); party.AddMember(session.Player); session.Send(PartyPacket.Create(party, true)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player)); foreach (Player member in party.Members) { if (member != session.Player) { party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(member)); } } }
public Party GetTestPlayerParty1() { Debug.Log("GetTestPlayerParty1"); // Leader Bod lord = BodManager.instance.CreateNewLordBod("Manfred", "Greenleaf", BodManager.instance.GetRandomPersonalityType(), true); // Player Party Party p = new Party(lord); // Body Guard Retainer Bod guard1 = BodManager.instance.CreateNewGuard("Derrik", "Alcroft"); p.AddRetainer(guard1); // 2 Fighting units Bod fl1 = BodManager.instance.CreateNewFreelancer("Jonas"); p.AddMember(fl1); Bod fl2 = BodManager.instance.CreateNewFreelancer("Cal"); p.AddMember(fl2); // 1 Non combatant Bod nc = BodManager.instance.CreateNewBod("Wendell"); p.AddMember(nc); return(p); }
static void Main(string[] args) { var jake = new Dog("Jake"); var duke = new Dog("Duke"); var lady = new Dog("Lady"); var dakota = new Dog("Dakota"); var dogsParty = new Party <Dog>(jake); dogsParty.AddMember(duke); dogsParty.AddMember(lady); dogsParty.AddMember(dakota); dogsParty.Dance(); dogsParty.RemoveMember(duke); dogsParty.VoteLeader(); dogsParty.Sing(); var frog1 = new Frog("Frog #1"); var frog2 = new Frog("Frog #2"); var frog3 = new Frog("Frog #3"); var frog4 = new Frog("Frog #4"); var frogsParty = new Party <Frog>(frog1); frogsParty.AddMember(frog2); frogsParty.AddMember(frog3); frogsParty.AddMember(frog4); frogsParty.Dance(); frogsParty.RemoveMember(frog3); frogsParty.VoteLeader(); frogsParty.Sing(); Console.ReadLine(); }
public Dungeon(string tiles) { party = new Party(); party.AddMember(new Warrior("afwaf"), new Pair(0, 0)); party.AddMember(new Priest("wa"), new Pair(2, 1)); party.AddMember(new Sorcerer("gr"), new Pair(1, 2)); tileset = tiles; }
private void GoToCamp(Character you, Character partner) { Party party = new Party(); Flags flags = new Flags(); party.AddMember(you); party.AddMember(partner); Camp camp = new Camp(party, flags); camp.Root.Invoke(); }
private void Handle(Player player, JoinPartyPacket packet) { Party party = Party.GetParty(packet.PartyID); if (party == null) { player.SendError("Party no longer exists!"); return; } if (!party.Invitations.Contains(player.AccountId)) { player.SendInfo("You must be invited to join a party!"); return; } if (player.Party != null) { if (player.Party.Leader == player) { player.Party.Disband(); } else { player.Party.RemoveMember(player); } } party.AddMember(player); }
public void FinalizePartyCreation() { m_party = CurrentParty; for (Int32 i = 0; i < 4; i++) { Character p_member = m_dummyChars[i].CreateCharacter(m_party); m_party.AddMember(i, p_member); } }
private void SavingCharactersInPartyThrowsNoErrors(int characterCount) { Party party = new Party(); for (int i = 0; i < characterCount; i++) { party.AddMember(CharacterList.TestEnemy()); } ToJson(party.GetSaveObject()); }
public void SaveLoadMaintainsBonusesFromEquipmentAndBuffsForNonPartyMemberCastedBuffs() { Party party = new Party(); Character dummy = CharacterList.TestEnemy(); Character buffCaster = CharacterList.TestEnemy(); buffCaster.Inventory.ForceAdd(new BrokenSword()); buffCaster.Equipment.AddEquip(buffCaster.Inventory, new BuffParams(buffCaster.Stats, buffCaster.Id), new BrokenSword()); buffCaster.AddBuff(new StrengthBoost()); Character buffRecipient = CharacterList.TestEnemy(); StrengthScalingPoison poison = new StrengthScalingPoison(); Debug.Log("BuffcasterID: " + buffCaster.Id); poison.Caster = new BuffParams(buffCaster.Stats, buffCaster.Id); buffRecipient.Buffs.AddBuff(poison); int initialStrength = buffCaster.Stats.GetStatCount(Stats.Get.TOTAL, StatType.STRENGTH); Assert.AreEqual(buffCaster.Stats.GetMultiplicativeBuffBonus(StatType.STRENGTH), StrengthBoost.STRENGTH_INCREASE_AMOUNT); Assert.AreEqual(buffCaster.Stats.GetFlatEquipmentBonus(StatType.STRENGTH), new BrokenSword().StatBonuses[StatType.STRENGTH]); party.AddMember(dummy); party.AddMember(CharacterList.TestEnemy()); party.AddMember(buffRecipient); PartySave retrieved = FromJson <PartySave>(ToJson(party.GetSaveObject())); Party party2 = new Party(); party2.InitFromSaveObject(retrieved); Stats spoofedCasterStats = party2.Collection.ToArray()[2].Buffs.ToArray()[0].BuffCaster; int spoofedStrength = spoofedCasterStats.GetStatCount(Stats.Get.TOTAL, StatType.STRENGTH); Assert.AreEqual(buffCaster.Stats.GetStatCount(Stats.Get.MOD, StatType.STRENGTH), spoofedCasterStats.GetStatCount(Stats.Get.MOD, StatType.STRENGTH)); Assert.AreEqual(StrengthBoost.STRENGTH_INCREASE_AMOUNT, spoofedCasterStats.GetMultiplicativeBuffBonus(StatType.STRENGTH)); Assert.AreEqual(new BrokenSword().StatBonuses[StatType.STRENGTH], spoofedCasterStats.GetFlatEquipmentBonus(StatType.STRENGTH)); Assert.AreEqual(buffCaster.Stats.GetStatCount(Stats.Get.TOTAL, StatType.STRENGTH), spoofedStrength); Assert.AreEqual(buffCaster.Stats, spoofedCasterStats); }
private void LoadingCharactersInPartyThrowsNoErrors(int characterCount) { Party party = new Party(); for (int i = 0; i < characterCount; i++) { party.AddMember(CharacterList.TestEnemy()); } string json = ToJson(party.GetSaveObject()); PartySave partySave = JsonUtility.FromJson <PartySave>(json); Party party2 = new Party(); party2.InitFromSaveObject(partySave); }
public Party GetTestBanditParty1() { Debug.Log("GetTestBanditParty1"); // Bandit Chief Bod banditChief = BodManager.instance.CreateNewFreelancer("Bandit Chief"); banditChief.SetFightingSkill(2); Party p = new Party(banditChief, "Bandit Party"); // 3 Bandits Bod b1 = BodManager.instance.CreateNewFreelancer("Bandit 1"); p.AddMember(b1); Bod b2 = BodManager.instance.CreateNewFreelancer("Bandit 2"); p.AddMember(b2); Bod b3 = BodManager.instance.CreateNewFreelancer("Bandit 3"); p.AddMember(b3); return(p); }
public void EquippedItemsAreSaved() { Character dummy = CharacterList.TestEnemy(); dummy.Inventory.ForceAdd(new BrokenSword()); dummy.Equipment.AddEquip(dummy.Inventory, new BuffParams(dummy.Stats, dummy.Id), new BrokenSword()); Party party = new Party(); party.AddMember(dummy); PartySave ps = party.GetSaveObject(); PartySave retrieved = FromJson <PartySave>(ToJson(party.GetSaveObject())); Party party2 = new Party(); party2.InitFromSaveObject(retrieved); Assert.AreEqual(party, party2); }
public Party CheckForMatch(CharClass player) { Party newParty = new Party(); bool partyFilled = false; newParty.AddMember(player); List <int> membersByPriority = new List <int>(); List <CharClass> eligibileMembers = new List <CharClass>(); List <int> matchedDungeons = player.queueDungeons; foreach (var member in queue) { if (member.name == player.name) { continue; } if (member.classType == player.classType) { continue; } else { membersByPriority.Add(member.queuePriority); } //for(int k = 0; k < matchedDungeons.Count; k++) //{ // if(!currentMatches.Contains(matchedDungeons.ElementAt(k))) // { // matchedDungeons.Remove(matchedDungeons.ElementAt(k)); // k--; // } //} } if (membersByPriority.Count == 0) { return(newParty); } membersByPriority.Sort(); for (int i = 0; i < membersByPriority.Count; i++) { foreach (var member in queue) { if (member.queuePriority == membersByPriority.ElementAt(i)) { eligibileMembers.Add(member); break; } } } foreach (var member in eligibileMembers) { List <int> currentMatches = new List <int>(); foreach (var dungeonID in member.queueDungeons) { if (!matchedDungeons.Contains(dungeonID)) { continue; } currentMatches.Add(dungeonID); } if (currentMatches.Count == 0) { continue; } for (int k = 0; k < matchedDungeons.Count; k++) { if (!currentMatches.Contains(matchedDungeons.ElementAt(k))) { matchedDungeons.Remove(matchedDungeons.ElementAt(k)); k--; } } bool isDuplicateClass = false; foreach (var partyMember in newParty.members) { if (member.classType == partyMember.classType) { isDuplicateClass = true; break; } } if (isDuplicateClass) { continue; } newParty.AddMember(member); if (newParty.NumMembers() == DUNGEON_MAX) { foreach (var dude in newParty.members) { dude.queueDungeons = new List <int>() { matchedDungeons.ElementAt(0) }; } partyFilled = true; lastFormed = DateTime.Now; break; } } if (partyFilled) { RemoveMembers(newParty); } return(newParty); }
private void HandleJoin(GameSession session, PacketReader packet) { string target = packet.ReadUnicodeString(); //Who invited the player int accept = packet.ReadByte(); //If the player accepted int unknown = packet.ReadInt(); //Something something I think it's dungeon not sure Player partyLeader = GameServer.Storage.GetPlayerByName(target); if (partyLeader == null) { return; } GameSession leaderSession = partyLeader.Session; if (accept == 1) { Party party = GameServer.PartyManager.GetPartyByLeader(partyLeader); if (party != null) { //Existing party, add joining player to all other party members. party.BroadcastPacketParty(PartyPacket.Join(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(session.Player)); party.AddMember(session.Player); } else { //Create new party Party newParty = new Party(GuidGenerator.Int(), 10, new List <Player> { partyLeader, session.Player }); GameServer.PartyManager.AddParty(newParty); //Send the party leader all the stuff for the joining player leaderSession.Send(PartyPacket.Join(session.Player)); leaderSession.Send(PartyPacket.UpdatePlayer(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(partyLeader)); partyLeader.PartyId = newParty.Id; party = newParty; } session.Player.PartyId = party.Id; //Create existing party based on the list of party members session.Send(PartyPacket.CreateExisting(partyLeader, party.Members)); session.Send(PartyPacket.UpdatePlayer(session.Player)); foreach (Player partyMember in party.Members) { //Skip first character because of the scuffed Create packet. For now this is a workaround and functions the same. if (partyMember.CharacterId != party.Members.First().CharacterId) { //Adds the party member to the UI session.Send(PartyPacket.Join(partyMember)); } //Update the HP for each party member. session.Send(PartyPacket.UpdateHitpoints(partyMember)); } //Sometimes the party leader doesn't get set correctly. Not sure how to fix. } else { //Send Decline message to inviting player leaderSession.Send(ChatPacket.Send(partyLeader, session.Player.Name + " declined the invitation.", ChatType.NoticeAlert2)); } }
private void JoinParty(GameSession session, string leaderName, bool accept, int unknown) { Player partyLeader = GameServer.Storage.GetPlayerByName(leaderName); if (partyLeader == null) { return; } GameSession leaderSession = partyLeader.Session; if (!accept) { //Send Decline message to inviting player leaderSession.Send(ChatPacket.Send(partyLeader, session.Player.Name + " declined the invitation.", ChatType.NoticeAlert2)); return; } Party party = GameServer.PartyManager.GetPartyByLeader(partyLeader); if (party != null) { //Existing party, add joining player to all other party members. party.BroadcastPacketParty(PartyPacket.Join(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(session.Player)); party.AddMember(session.Player); if (party.PartyFinderId != 0) { if (party.Members.Count >= party.MaxMembers) { party.PartyFinderId = 0; //Hide from party finder if full party.BroadcastPacketParty(MatchPartyPacket.RemoveListing(party)); party.BroadcastPacketParty( MatchPartyPacket.SendListings(GameServer.PartyManager.GetPartyFinderList())); party.BroadcastPacketParty(PartyPacket.MatchParty(null)); } else { session.Send( MatchPartyPacket.CreateListing(party)); //Add recruitment listing for newly joining player session.Send(PartyPacket.MatchParty(party)); } } } else { //Create new party Party newParty = new(10, new List <Player> { partyLeader, session.Player }); GameServer.PartyManager.AddParty(newParty); //Send the party leader all the stuff for the joining player leaderSession.Send(PartyPacket.Join(session.Player)); leaderSession.Send(PartyPacket.UpdatePlayer(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(partyLeader)); party = newParty; } //Create existing party based on the list of party members session.Send(PartyPacket.CreateExisting(partyLeader, party.Members)); session.Send(PartyPacket.UpdatePlayer(session.Player)); foreach (Player partyMember in party.Members) { //Skip first character because of the scuffed Create packet. For now this is a workaround and functions the same. if (partyMember.CharacterId != party.Members.First().CharacterId) { //Adds the party member to the UI session.Send(PartyPacket.Join(partyMember)); } //Update the HP for each party member. session.Send(PartyPacket.UpdateHitpoints(partyMember)); } }
// Use this for initialization void Start() { var loadedData = LoadBoardData(); // I. Create board cells = new BattleboardCell[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { cells[i, j] = Instantiate(cellPrefab, transform.position + new Vector3(i, 0, j), cellPrefab.transform.rotation).GetComponent <BattleboardCell>(); var redefinedCell = loadedData.cells.Where(p => p.x == i && p.y == j).FirstOrDefault <CellData>(); if (null != redefinedCell) { cells[i, j].walkable = redefinedCell.walkable; } if (cells[i, j].walkable) { cells[i, j].Clicked += onCellClicked; cells[i, j].MouseEnter += onCellMouseEnter; cells[i, j].MouseExit += onCellMouseExit; } } } // II. Create characters playerParty = new Party(); enemyParty = new Party(); foreach (var _party in loadedData.parties) { var isEnemyParty = _party.enemy; foreach (var _char in _party.characters) { var _x = _char.x; var _y = _char.y; GameObject character = InstantiateCharacter(_char.prefab, _x, _y); cells[_x, _y].Character = character.GetComponent <Character>(); if (_char.maxHP != 0) // yeah, so can't set 0 hp/ap in data file, but do we need it really? { cells[_x, _y].Character.MaxHP = _char.maxHP; } if (_char.maxAP != 0) { cells[_x, _y].Character.MaxAP = _char.maxAP; } if (!String.IsNullOrEmpty(_char._name)) { cells[_x, _y].Character.Name = _char._name; } cells[_x, _y].Character.transform.eulerAngles = _char.Direction; cells[_x, _y].Character.Dead += onCharacterDead; cells[_x, _y].Character.Moved += onCharacterMoved; cells[_x, _y].Character.Attacked += onCharacterAttacked; cells[_x, _y].Character.Hit += onCharacterHit; if (isEnemyParty) { enemyParty.AddMember(cells[_x, _y].Character); } else { playerParty.AddMember(character.GetComponent <Character>()); } cells[_x, _y].Character.Avatar.GetComponentInChildren <Image>().color = isEnemyParty ? Color.red : Color.green; // just #temporarily turn on halo effect for enemies Behaviour halo = (Behaviour)cells[_x, _y].Character.GetComponent("Halo"); halo.enabled = isEnemyParty; } } /// III Create turn queue turnQ = new Queue <Character>(); // some algorithm of forming the Q (player order may be set upfront, like in Banner Saga) for (int i = 0; i < playerParty.Count(); i++) { turnQ.Enqueue(playerParty[i]); } for (int i = 0; i < enemyParty.Count(); i++) { turnQ.Enqueue(enemyParty[i]); } PositionCharactersAvatars(); PrepareCharacterForTurn(turnQ.Peek()); /// IV Other stuff // calculate it once and forever adjacentCellsDistance = Vector3.Distance(cells[0, 0].transform.position, cells[1, 1].transform.position); // some event listeners ButtonEndTurn.onClick.AddListener(TaskOnButtonEndTurnClick); fsm.PushState(inputEnabledState); // input enabled is the default state }
public override void ParseMessage(int index, BgoProtocolReader br) { ushort msgType = br.ReadUInt16(); switch ((Request)msgType) { case Request.RecruitLevel: SendRecruitLevel(index); break; case Request.PartyInvitePlayer: uint partyInvitedPlayerId = br.ReadUInt32(); if (Server.GetClientByPlayerId(partyInvitedPlayerId.ToString()).Character.partyId != 0) { SendPartyIgnore(Server.GetClientByPlayerId(partyInvitedPlayerId.ToString()).index, Server.GetClientByIndex(index).Character.name, 1); break; } Party p = Server.GetPartyById(Server.GetClientByIndex(index).Character.partyId); if (p == null) { SendPartyInvite(Server.GetClientByPlayerId(partyInvitedPlayerId.ToString()).index, (uint)index, Server.GetClientByIndex(index).playerId, Server.GetClientByIndex(index).Character.name); break; } p.InviteMember(partyInvitedPlayerId, index); break; case Request.PartyAccept: uint partyAcceptPartyId = br.ReadUInt32(); uint partyAcceptInviterId = br.ReadUInt32(); bool partyAcceptBool = br.ReadBoolean(); if (!partyAcceptBool) { SendPartyIgnore(Server.GetClientByPlayerId(partyAcceptInviterId.ToString()).index, Server.GetClientByIndex(index).Character.name, 2); break; } Party p2 = Server.GetPartyById(partyAcceptPartyId); if (p2 == null) { Server.Parties.Add(partyAcceptPartyId, new Party(Server.GetClientByPlayerId(partyAcceptInviterId.ToString()))); Party p3 = Server.GetPartyById(partyAcceptPartyId); p3.AddMember(Server.GetClientByIndex(index)); break; } p2.AddMember(Server.GetClientByIndex(index)); break; case Request.PartyLeave: Party p4 = Server.GetPartyById(Server.GetClientByIndex(index).Character.partyId); if (p4 != null) { p4.RemoveMember(Server.GetClientByIndex(index)); } break; default: Log.Add(LogSeverity.ERROR, string.Format("Unknown msgType \"{0}\" on {1}Protocol.", (Request)msgType, protocolID)); break; } }