Пример #1
0
        public ContractTracker(Player player, CharacterPropertiesContractRegistry contract)
        {
            Init(contract.ContractId, player);

            DeleteContract       = contract.DeleteContract;
            SetAsDisplayContract = contract.SetAsDisplayContract;
        }
Пример #2
0
        public GameEventSendClientContractTracker(Session session, CharacterPropertiesContractRegistry contract) : base(GameEventType.SendClientContractTracker, GameMessageGroup.UIQueue, session)
        {
            var contractTracker = new ContractTracker(session.Player, contract);

            Writer.Write(contractTracker);
            Writer.Write(Convert.ToUInt32(contractTracker.DeleteContract));
            Writer.Write(Convert.ToUInt32(contractTracker.SetAsDisplayContract));
        }
        /// <summary>
        /// Adds a new contract to the player's registry
        /// </summary>
        public bool Add(uint contractId)
        {
            var datContract = GetContractFromDat(contractId);

            if (datContract == null)
            {
                if (Debug)
                {
                    Console.WriteLine($"{Player.Name}.ContractManager.Add({contractId}): Contract not found in DAT file.");
                }
                return(false);
            }

            if (IsFull)
            {
                if (Player != null)
                {
                    //Player.Session.Network.EnqueueSend(new GameEventWeenieError(Player.Session, WeenieError.ContractError));
                    //what happened here in retail?

                    Player.Session.Network.EnqueueSend(new GameMessageSystemChat($"You currently have the maximum amount of contracts for this character and cannot take on another! You must abandon at least one contract before you can accept the contract for {datContract.ContractName}.", ChatMessageType.Broadcast));
                }
                return(false);
            }

            var existing = GetContract(contractId);

            if (existing == null)
            {
                // add new contract entry
                var info = new CharacterPropertiesContractRegistry
                {
                    CharacterId          = Player.Guid.Full,
                    ContractId           = datContract.ContractId,
                    DeleteContract       = false,
                    SetAsDisplayContract = false,
                };
                if (Debug)
                {
                    Console.WriteLine($"{Player.Name}.ContractManager.Add({contractId}): added contract: {datContract.ContractName}");
                }
                Contracts.Add(info);
                if (Player != null)
                {
                    Player.CharacterChangesDetected = true;
                    Player.Session.Network.EnqueueSend(new GameEventSendClientContractTracker(Player.Session, info));
                }

                RefreshMonitoredQuestFlags();
            }
            else
            {
                if (Debug)
                {
                    Console.WriteLine($"{Player.Name}.ContractManager.Add({contractId}): contract for {datContract.ContractName} already exists in registry.");
                }

                // contracts dupes are also successful without actually duping into registry.
                //return false;
            }

            return(true);
        }