public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); CreateSocietyData(); //Version 0 if (version >= 0) { m_Player = reader.ReadMobile() as PlayerMobile; int jobProgressCount = reader.ReadInt(); for (int a = 0; a < jobProgressCount; a++) { SocietyJob job = reader.ReadItem() as SocietyJob; SocietiesJobContract jobContract = reader.ReadItem() as SocietiesJobContract; double primaryProgress = reader.ReadDouble(); double secondaryProgress = reader.ReadDouble(); if (job == null) { continue; } if (job.Deleted) { continue; } SocietyJobPlayerProgress jobProgress = new SocietyJobPlayerProgress(job); jobProgress.m_JobContract = jobContract; jobProgress.m_ProgressAmount = primaryProgress; jobProgress.m_TurnedInAmount = secondaryProgress; m_JobProgress.Add(jobProgress); } int recordedSocietyGroupDataCount = reader.ReadInt(); for (int a = 0; a < recordedSocietyGroupDataCount; a++) { SocietiesGroupType societyGroupType = (SocietiesGroupType)reader.ReadInt(); int pointsAvailable = reader.ReadInt(); int monthlyPoints = reader.ReadInt(); int lifetimePoints = reader.ReadInt(); int pointsSpent = reader.ReadInt(); foreach (SocietyGroupPlayerData societyGroupPlayerData in m_SocietyPlayerData) { if (societyGroupPlayerData.m_SocietyGroupType == societyGroupType) { societyGroupPlayerData.m_PointsAvailable = pointsAvailable; societyGroupPlayerData.m_MontlyPoints = monthlyPoints; societyGroupPlayerData.m_LifetimePoints = lifetimePoints; societyGroupPlayerData.m_PointsSpent = pointsSpent; break; } } } } //----- if (m_Player != null) { m_Player.m_SocietiesPlayerSettings = this; } else { Delete(); } }
public void PlayerAccept(PlayerMobile player) { if (player == null) { return; } if (player.Backpack == null) { return; } if (AccountHasCompleted(player)) { player.SendMessage("A character on this account has already completed this job."); return; } SocietyJobPlayerProgress playerJobProgress = Societies.GetSocietiesJobPlayerProgress(player, this); if (playerJobProgress == null) { if (player.Backpack.TotalItems >= player.Backpack.MaxItems) { player.SendMessage("You have too many items in your backpack to accept a new job contract."); return; } else { playerJobProgress = new SocietyJobPlayerProgress(this); player.m_SocietiesPlayerSettings.m_JobProgress.Add(playerJobProgress); player.SendMessage("You accept the job offer. A contract has been placed in your backpack."); SocietiesJobContract jobContract = new SocietiesJobContract(this); playerJobProgress.m_JobContract = jobContract; jobContract.m_Player = player; player.SendSound(0x249); player.Backpack.DropItem(jobContract); } } else { List <SocietiesJobContract> m_ContractsHeld = player.Backpack.FindItemsByType <SocietiesJobContract>(); bool foundMatch = false; foreach (SocietiesJobContract contract in m_ContractsHeld) { if (contract.m_Job == this) { foundMatch = true; break; } } if (foundMatch) { player.SendMessage("You already have a contract for this job in your backpack."); return; } if (player.Backpack.TotalItems >= player.Backpack.MaxItems) { player.SendMessage("You have too many items in your backpack to receive a replacement contract for this job."); return; } else { //Delete Any Old Instances of this Contract Created by Player Queue m_Queue = new Queue(); foreach (Item item in World.Items.Values) { if (item is SocietiesJobContract) { SocietiesJobContract oldContract = item as SocietiesJobContract; if (oldContract == null) { continue; } if (oldContract.m_Job == this && oldContract.m_Player == player) { m_Queue.Enqueue(oldContract); } } } while (m_Queue.Count > 0) { Item item = (Item)m_Queue.Dequeue(); item.Delete(); } SocietiesJobContract jobContract = new SocietiesJobContract(this); jobContract.m_Player = player; playerJobProgress.m_JobContract = jobContract; player.Backpack.DropItem(jobContract); player.SendSound(0x249); player.SendMessage("You have previouly accepted this job offer, and receive a replacement contract for the job."); return; } } }