public Result doRoll(Argument arg, CharacterData attacker, CharacterData defender, CharacterData world,
                             ArgumentFeedback argFeedback)
        {
            Factor rollFactor = new Factor()
            {
                NumberOfDice = 2, DiceType = 6
            };
            Result result;
            double subBonus = attacker.getProperty("subterfugeBonus"), nonSubBonus = attacker.getProperty("nonSubterfugeBonus"), analyzeBonus = attacker.getProperty("analyzeBonus"), subPenalty = attacker.getProperty("subterfugePenalty");
            double defValue = defender.getProperty(arg.DefenderCheckProperty), attValue = attacker.getProperty(arg.AttackerCheckProperty);


            //Check bonuses
            if (arg.IsSubterfugeArgument)
            {
                rollFactor.Numerator = subBonus - subPenalty;
            }
            else
            {
                rollFactor.Numerator = nonSubBonus;
            }
            //keep at 1
            analyzeBonus          = analyzeBonus >= 1 ? 1 : 0;
            rollFactor.Numerator += analyzeBonus;

            //Add Roll
            attValue += Argument.doRoll(rollFactor);

            argFeedback.rollResult = attValue;

            if (Double.IsNaN(defValue))
            {
                defValue = 0;
            }

            //Perform check
            if (attValue - defValue > 8)//Great success
            {
                result = Result.GreatSuccess;
            }
            else if (attValue - defValue > 6)//Success
            {
                result = Result.Success;
            }
            else//Failure
            {
                result = Result.Failure;
            }
            argFeedback.result = result;
            return(result);
        }
示例#2
0
        /// <summary>
        /// Overwrite this if you are SoM action
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <param name="world"></param>
        public ArgumentFeedback doArgument(CharacterData attacker, CharacterData defender, CharacterData world)
        {
            if (!checkCharactersValid(attacker, defender))
            {
                return(null);
            }

            //Reset feedback atts
            ArgFeedback = new ArgumentFeedback();
            ArgFeedback.argumentName = this.ToString();

            //Set Characters
            this.Attacker = attacker;
            this.Defender = defender;
            this.World    = world;

            result = RollBehavior.doRoll(this, attacker, defender, world, ArgFeedback);
            doEffects();

            return(ArgFeedback);
        }
示例#3
0
        /// <summary>
        /// Game decision point. This method gets messages from connection and decides what arguments to call, as well
        /// as taking care of runtime handlers for SoM requests
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="player"></param>
        /// <param name="data"></param>
        public void getMessageFromConnection(Messages.GameMessages msg, DataPlayer player, List <object> data)
        {
            if (!checkTurn(player))//Not right turn?
            {
                (this as IGameObservable).notifyObservers(Messages.GameMessages.NotPlayerTurn, player, null);
                Match.updateTranscript("Not your turn");
                return;
            }
            CharacterData    attacker = Turn == 0?Player1.Character:Player2.Character, defender = Turn == 0?Player2.Character:Player1.Character;
            ArgNames         actionName  = 0;
            ArgumentFeedback argFeedback = null;

            if (waiting && msg != Messages.GameMessages.somChosen)
            {
                Match.updateTranscript("Waiting for SOM");
                return;
            }

            switch (msg)
            {
            ///This case handles the response from a request to get SoM from the user
            ///We need to translate the response (SoMName,value) into values the Handler needs (JoySorrowValue,AngerFearValue)
            case Messages.GameMessages.somChosen:
                SOM name = (SOM)data[0];
                switch (name)
                {
                case SOM.Joy:
                    argFeedback = SoMHandler(1, 0);
                    break;

                case SOM.Sorrow:
                    argFeedback = SoMHandler(-1, 0);
                    break;

                case SOM.Anger:
                    argFeedback = SoMHandler(0, 1);
                    break;

                case SOM.Fear:
                    argFeedback = SoMHandler(0, -1);
                    break;
                }
                waiting = false;    //Just in case
                break;

            case Messages.GameMessages.Trick:
                actionName  = ArgNames.Trick;
                argFeedback = arguments[actionName].doArgument(attacker, defender, World);
                if ((arguments[actionName] as Trick).repeatTurn())
                {
                    Turn--;    //We turn it back then the regular turn counter turns it back to my turn
                }
                break;

            case Messages.GameMessages.Manipulate:
                actionName = ArgNames.Manipulate;
                goto case Messages.GameMessages.SoMDependentArgument;

            case Messages.GameMessages.Taunt:
                actionName = ArgNames.Taunt;
                goto case Messages.GameMessages.SoMDependentArgument;

            case Messages.GameMessages.Focus:
                actionName = ArgNames.Focus;
                goto case Messages.GameMessages.SoMDependentArgument;

            case Messages.GameMessages.Empathy:
                actionName  = ArgNames.Empathy;
                argFeedback = (arguments[actionName] as Empathy).doArgument(attacker, defender, World);
                if (argFeedback != null && argFeedback.result == Result.None)
                {
                    Match.updateTranscript("Empathy cannot be used\n");
                }
                break;

            case Messages.GameMessages.Bluff:
                actionName = ArgNames.Bluff;
                goto case Messages.GameMessages.GenericArgument;

            case Messages.GameMessages.Charm:
                actionName = ArgNames.Charm;
                goto case Messages.GameMessages.GenericArgument;

            case Messages.GameMessages.Coerce:
                actionName = ArgNames.Coerce;
                goto case Messages.GameMessages.GenericArgument;

            case Messages.GameMessages.Convince:
                actionName = ArgNames.Convince;
                goto case Messages.GameMessages.GenericArgument;

            case Messages.GameMessages.Scare:
                actionName = ArgNames.Scare;
                goto case Messages.GameMessages.GenericArgument;

            case Messages.GameMessages.GenericArgument:
                argFeedback = arguments[actionName].doArgument(attacker, defender, World);
                break;

            case Messages.GameMessages.SoMDependentArgument:
                (arguments[actionName] as SoMDependentArgument).Selector = this;

                argFeedback = (arguments[actionName] as SoMDependentArgument).doArgument(attacker, defender, World);
                //If true then it succeeded so it needs to get SoM
                if (argFeedback == null)
                {
                    waiting = true;
                }
                break;
            }//End Switch

            //Update transcript if there is feedback
            if (argFeedback != null)
            {
                argFeedback.playerName = player.PlayerName;
                Match.updateTranscript(argFeedback);
            }

            if (!waiting)
            {
                //Check Game over
                if (Match.Goal.isGoalReached(defender))
                {
                    (this as IGameObservable).notifyObservers(Messages.GameMessages.GameOver, Match.Player1, null);
                    (this as IGameObservable).notifyObservers(Messages.GameMessages.GameOver, Match.Player2, null);
                }
                else//Not over
                {
                    //Tell players to update and go to next turn
                    (this as IGameObservable).notifyObservers(Messages.GameMessages.ArgumentDone, player, null);
                    Turn = (Turn + 1) % 2;
                }
            }
        }
        public Result doRoll(Argument arg, CharacterData attacker, CharacterData defender, CharacterData world, ArgumentFeedback argFeedback)
        {
            double attackerJS = attacker.MyAttributes["StateOfMindJoySorrow"], attackerAF = attacker.MyAttributes["StateOfMindAngerFear"], defenderJS = defender.MyAttributes["StateOfMindJoySorrow"], defenderAF = defender.MyAttributes["StateOfMindAngerFear"];

            argFeedback.result = Result.None;
            if ((attackerJS == 2 && attackerAF == 2) || (defenderJS == 2 && defenderAF == 2))//Tranquility, so no action
            {
                return(Result.None);
            }
            if (Math.Abs(attackerJS - defenderJS) > 1 || Math.Abs(attackerAF - defenderAF) > 1)//not the same SoM
            {
                return(Result.None);
            }
            if ((attackerJS == 2 && defenderJS != 2) || (defenderJS == 2 && attackerJS != 2))
            {
                return(Result.None);
            }
            if ((attackerAF == 2 && defenderAF != 2) || (attackerAF != 2 && defenderAF == 2))
            {
                return(Result.None);
            }

            return((new NormalRollBehavior()).doRoll(arg, attacker, defender, world, argFeedback));
        }
 public Result doRoll(Argument arg, CharacterData attacker, CharacterData defender, CharacterData world, ArgumentFeedback argFeedback)
 {
     argFeedback.result = Result.Success;
     return(Result.Success);
 }
示例#6
0
 public void updateTranscript(ArgumentFeedback f)
 {
     LastArgument = f;
     updateTranscripts(f.argumentName, f.rollResult, f.affectedProperty, f.affectedValues, f.result, f.playerName);
 }