public async Task ProgressInteractiveReactions(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { if (!ProgressTrackerInfo.IsProgressTrackerMessage(message)) { return; } if (reaction.Emote.IsSameAs(DecreaseEmoji)) { DecreaseProgress(message); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); } if (reaction.Emote.IsSameAs(IncreaseEmoji)) { IncreaseProgress(message); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); } if (reaction.Emote.IsSameAs(oldFullEmoji) || reaction.Emote.IsSameAs(FullEmoji)) { IncreaseProgressFullCheck(message); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); } if (reaction.Emote.IsSameAs(RollEmoji)) { var tracker = new ProgressTrackerInfo().PopulateFromMessage(message); var roll = new ActionRoll(0, tracker.ActionDie, $"{ProgressResources.ProgressRollFor}{tracker.Description}"); await channel.SendMessageAsync(roll.ToString()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); } return; }
private PlayInfo GetLongPassRolls(PlayInfo _currentPlay) { PlayerData attacker = _currentPlay.Attacker; PlayerData defender = _currentPlay.Defender; _currentPlay.AttackerRoll = ActionRoll.LongPass(attacker); if (defender != null) { _currentPlay.DefensiveAction = PlayerAction.Block; _currentPlay.DefenderRoll = ActionRoll.Block(defender); } _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Passing); if (_currentPlay.Marking == MarkingType.Close) { _currentPlay.AttackerRoll *= 0.9f; } if (defender != null) { _currentPlay.DefendingBonusChance = GetPlayerAttributeBonus(defender.Blocking); } return(ApplyBuffs(_currentPlay)); }
override public void OnDeactivate() { // Time.timeScale = 1; Action.SetSuccess(); Action = null; base.OnDeactivate(); }
public void ActionRollTest1() { var roll = new ActionRoll(-10) { ActionDie = 6 }; Assert.AreEqual(-4, roll.ActionScore); Assert.IsTrue(roll.ToString() != string.Empty); }
private PlayInfo GetSprintRolls(PlayInfo _currentPlay) { PlayerData attacker = _currentPlay.Attacker; PlayerData defender = _currentPlay.Defender; _currentPlay.AttackerRoll = ActionRoll.Sprint(attacker); _currentPlay.AttackingBonusChance = 100; _currentPlay.AttackerRoll *= 2f; return(ApplyBuffs(_currentPlay)); }
private async Task ReactionResolveScene(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { if (!IsSceneChallengeMessage(message)) { return; } SceneChallengeInfo scene = new SceneChallengeInfo().FromMessage(message); var roll = new ActionRoll(0, scene.ActionDie, String.Format(SceneChallengeResources.ResolveSceneRoll, scene.Description)); await channel.SendMessageAsync(roll.ToString()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); }
private async Task ReactionLocateObjectiveEvent(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { if (!IsDelveMessage(message)) { return; } await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); DelveInfo delve = new DelveInfo().FromMessage(DelveService, message); var roll = new ActionRoll(0, delve.ActionDie, String.Format(DelveResources.LocateObjectiveRoll, delve.SiteName)); await channel.SendMessageAsync(roll.ToString()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); }
protected override void Initialize(ActionBase action) { base.Initialize(action); Action = action as ActionRoll; Action.Direction = Owner.BlackBoard.DesiredDirection; CurrentMoveTime = 0; CurrentRotationTime = 0; StartRotation = Transform.rotation; StartPosition = Transform.position; Vector3 finalDir; if (Action.ToTarget != null) { finalDir = Action.ToTarget.Position - Transform.position; finalDir.Normalize(); FinalPosition = Action.ToTarget.Position - finalDir * Owner.BlackBoard.WeaponRange; } else { finalDir = Action.Direction; FinalPosition = StartPosition + Action.Direction * Owner.BlackBoard.RollDistance; } string AnimName = Owner.AnimSet.GetRollAnim(Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState); CrossFade(AnimName, 0.1f); FinalRotation.SetLookRotation(finalDir); RotationTime = Vector3.Angle(Transform.forward, finalDir) / 1000.0f; MoveTime = AnimEngine[AnimName].length * 0.85f; EndOfStateTime = AnimEngine[AnimName].length * 0.9f + Time.timeSinceLevelLoad; RotationOk = RotationTime == 0; PositionOK = false; Owner.BlackBoard.MotionType = E_MotionType.Roll; if (Effect) { CombatEffectsManager.Instance.StartCoroutine(CombatEffectsManager.Instance.PlayAndStop(Effect, 0.1f)); } }
public async Task Action([Summary("Modifier for the action roll")][Remainder] string ModiferAndFluff = "") { int mod = 0; var regex = Regex.Match(ModiferAndFluff, @"[\+-]?\d+"); if (regex.Success) { Int32.TryParse(regex.Value, out mod); } var roll = new ActionRoll(mod); await ReplyAsync(roll.ToString()); }
//----------------------------------// /// <summary> /// Initialize a cache with the specified max culmunative item size. /// </summary> public Cache(long maxSize = 1000, Func <TValue, long> getItemSize = null) { MaxSize = maxSize; MaxItemSize = MaxSize / 1000; if (MaxItemSize < 1) { MaxItemSize = 1; } _queue = new ArrayQueue <TKey>(); _lookup = new Dictionary <TKey, Teple <long, long, TValue> >(); _getItemSize = getItemSize; _onRemoved = new ActionRoll <TValue>(); _lock = new Lock(); }
private PlayInfo GetDribbleRolls(PlayInfo _currentPlay) { PlayerData attacker = _currentPlay.Attacker; PlayerData defender = _currentPlay.Defender; _currentPlay.AttackerRoll = ActionRoll.Dribble(attacker); _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Tackling); if (_currentPlay.Marking == MarkingType.Close) { _currentPlay.AttackerRoll *= 0.75f; } if (defender != null) { _currentPlay.DefensiveAction = PlayerAction.Tackle; _currentPlay.DefenderRoll = ActionRoll.Tackle(defender); _currentPlay.DefendingBonusChance = GetPlayerAttributeBonus(defender.Tackling); } return(ApplyBuffs(_currentPlay)); }
//----------------------------------// /// <summary> /// Construct a new web context for the specified alchemy user context. /// </summary> public HttpClient(HttpServer server) { // persist the server Server = server; _timeout = new Timer(_timeoutMilliseconds, Dispose); OnRequest = new ActionPop <HttpRequest>(); OnErrorRoll = new ActionRoll <Exception>(); // create the encoder and decoder _encoder = Encoding.UTF8.GetEncoder(); _requests = new ArrayRig <HttpRequest>(); Connections = new Capsule <HttpConnection>(); _lock = new Lock(); Log.Info("New connection '" + this + "'."); }
private PlayInfo GetPassRolls(PlayInfo _currentPlay, PlayInfo _lastPlay) { PlayerData attacker = _currentPlay.Attacker; PlayerData defender = _currentPlay.Defender; if (_lastPlay != null && _lastPlay.OffensiveAction == PlayerAction.Cross && _lastPlay.IsActionSuccessful) { _currentPlay.AttackerRoll = ActionRoll.HeaderPass(attacker); if (defender != null) { _currentPlay.DefensiveAction = PlayerAction.Block; _currentPlay.DefenderRoll = ActionRoll.HeaderBlock(defender); } } else { _currentPlay.AttackerRoll = ActionRoll.Pass(attacker); if (defender != null) { _currentPlay.DefensiveAction = PlayerAction.Block; _currentPlay.DefenderRoll = ActionRoll.Block(defender); } } _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Passing); if (_currentPlay.Marking == MarkingType.Close) { _currentPlay.AttackingBonusChance = Mathf.FloorToInt(_currentPlay.AttackingBonusChance * 0.9f); } if (defender != null) { _currentPlay.DefendingBonusChance = GetPlayerAttributeBonus(defender.Blocking); } return(ApplyBuffs(_currentPlay)); }
public void ActionRollTest2() { var complicationRoll = new ActionRoll { ActionDie = 6, ChallengeDie1 = 10, ChallengeDie2 = 10 }; var opportunityRoll = new ActionRoll { ActionDie = 6, ChallengeDie1 = 5, ChallengeDie2 = 5 }; var strongHit = new ActionRoll { ActionDie = 6, ChallengeDie1 = 5, ChallengeDie2 = 4 }; var weakHit = new ActionRoll { ActionDie = 5, ChallengeDie1 = 2, ChallengeDie2 = 5 }; var miss = new ActionRoll { ActionDie = 3, ChallengeDie1 = 3, ChallengeDie2 = 4 }; Assert.AreEqual(ActionResources.Complication, complicationRoll.ResultText()); Assert.AreEqual(ActionResources.Opportunity, opportunityRoll.ResultText()); Assert.AreEqual(ActionResources.Strong_Hit, strongHit.ResultText()); Assert.AreEqual(ActionResources.Weak_Hit, weakHit.ResultText()); Assert.AreEqual(ActionResources.Miss, miss.ResultText()); }
// 生成动作 static public ActionBase Create(E_Type type) { int index = (int)type; ActionBase a; if (m_UnusedActions[index].Count > 0) { a = m_UnusedActions[index].Dequeue(); } else { switch (type) { case E_Type.E_IDLE: a = new ActionIdle(); break; case E_Type.E_MOVE: a = new ActionMove(); break; case E_Type.E_GOTO: a = new ActionGoTo(); break; case E_Type.E_COMBAT_MOVE: a = new ActionCombatMove(); break; case E_Type.E_ATTACK: a = new ActionAttack(); break; case E_Type.E_ATTACK_ROLL: a = new ActionAttackRoll(); break; case E_Type.E_ATTACK_WHIRL: a = new ActionAttackWhirl(); break; case E_Type.E_INJURY: a = new ActionInjury(); break; case E_Type.E_DAMAGE_BLOCKED: a = new ActionDamageBlocked(); break; case E_Type.E_BLOCK: a = new ActionBlock(); break; case E_Type.E_ROLL: a = new ActionRoll(); break; case E_Type.E_INCOMMING_ATTACK: a = new ActionIncommingAttack(); break; case E_Type.E_WEAPON_SHOW: a = new ActionWeaponShow(); break; case E_Type.E_Rotate: a = new ActionRotate(); break; case E_Type.E_USE_LEVER: a = new ActionUseLever(); break; case E_Type.E_PLAY_ANIM: a = new ActionPlayAnim(); break; case E_Type.E_PLAY_IDLE_ANIM: a = new ActionPlayIdleAnim(); break; case E_Type.E_DEATH: a = new ActionDeath(); break; case E_Type.E_KNOCKDOWN: a = new ActionKnockdown(); break; case E_Type.E_Teleport: a = new ActionTeleport(); break; default: Debug.LogError("no Action to create"); return(null); } } a.Reset(); a.SetActive(); m_ActionsInAction.Add(a); return(a); }
/// <summary> /// Add a key to replace in strings with the specified value. /// </summary> public void Add(string key, ActionRoll <StringBuilder, string, int> onParsed) { _tree.Add(new Teple <string, ActionRoll <StringBuilder, string, int> >( null, new ActionRoll <StringBuilder, string, int>(onParsed)), key.ToCharArray()); }
/// <summary> /// Add a key to replace in strings with the specified value. /// </summary> public void Add(string key, string value, ActionRoll <StringBuilder, string, int> onParsed) { _tree.Add(new Teple <string, ActionRoll <StringBuilder, string, int> >(value, onParsed), key.ToCharArray()); }
public PlayInfo GetShotResults(PlayInfo _currentPlay, PlayInfo _lastPlay) { PlayerData attacker = _currentPlay.Attacker; PlayerData defender = _currentPlay.Defender; Zone zone = attacker.Team.GetTeamZone(_currentPlay.Zone); float distanceModifier = DistanceModifiers.ShotModifier(zone); if (_currentPlay.OffensiveAction == PlayerAction.Shot) { if (_lastPlay.Event == MatchEvent.Fault) { _currentPlay.AttackerRoll = ActionRoll.Freekick(attacker); _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Freekick); } else if (_lastPlay.Event == MatchEvent.PenaltyShot) { _currentPlay.AttackerRoll = ActionRoll.Penalty(attacker); _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Penalty); } else { _currentPlay.AttackerRoll = ActionRoll.Shoot(attacker); _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Shooting); } } else if (_currentPlay.OffensiveAction == PlayerAction.Header) { _currentPlay.AttackerRoll = ActionRoll.Header(attacker); _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Heading); } _currentPlay.AttackerRoll *= attacker.FatigueModifier(); _currentPlay.AttackerRoll *= distanceModifier; _currentPlay.AttackerRoll *= _currentPlay.AttackingBonus; if (_currentPlay.Marking == MarkingType.Close) { _currentPlay.AttackerRoll *= 0.5f; } _currentPlay.DefenderRoll = ActionRoll.Keeper(defender); _currentPlay.DefenderRoll *= defender.FatigueModifier(); //Roll dice for shooter and keeper _currentPlay = playDiceRolls.GetShotOnGoalResult(_currentPlay); //CHECK ATTACKING X DEFENDING if (_currentPlay.AttackerRoll <= _currentPlay.DefenderRoll) { int roll = Dice.Roll(20); if (_currentPlay.DefenseExcitment == 0 && roll < 5) { _currentPlay.Event = MatchEvent.CornerKick; } else { _currentPlay.Event = _lastPlay.Event == MatchEvent.PenaltyShot ? MatchEvent.PenaltySaved : MatchEvent.ShotSaved; if (_currentPlay.OffensiveAction == PlayerAction.Shot) { _currentPlay.Attacker.MatchStats.ShotsOnGoal++; } else if (_currentPlay.OffensiveAction == PlayerAction.Header) { _currentPlay.Attacker.MatchStats.HeadersOnGoal++; } } _currentPlay.IsActionSuccessful = false; if (_currentPlay.Event == MatchEvent.CornerKick) { if (_currentPlay.OffensiveAction == PlayerAction.Shot) { _currentPlay.Attacker.MatchStats.ShotsMissed++; _currentPlay.Attacker.Team.MatchStats.ShotsMissed++; } else if (_currentPlay.OffensiveAction == PlayerAction.Header) { _currentPlay.Attacker.MatchStats.HeadersMissed++; _currentPlay.Attacker.Team.MatchStats.HeadersMissed++; } } } else { _currentPlay.IsActionSuccessful = true; _currentPlay.Event = MatchEvent.Goal; } return(_currentPlay); }