public void AddStun(float value) { float valueToAdd = UsefulActions.RandomiseNumber(value); float clampedValue = GetHealthAsAPercentage(); clampedValue = UsefulActions.ClampValue(clampedValue); //Allowing the value to equal 0 leads to infinity, which bugs the game valueToAdd /= clampedValue; //Recover slower the lower your health is clampedValue = GetStaminaAsAPercentage(); clampedValue = UsefulActions.ClampValue(clampedValue); //Allowing the value to equal 0 leads to infinity, which bugs the game valueToAdd /= clampedValue; //Recover slower the lower your stamina is valueToAdd /= Match.instance.GetRecoveryMultiplier(); valueToAdd *= Match.instance.StunnedMultiplier(); valueToAdd = (IsStunned()) ? valueToAdd / 2 : valueToAdd; //Reduce stun added to already stunned targets. Essentially a softcap if (UsefulActions.RandomiseChance(momentum * QUICK_RECOVER_CHANCE_SCALER)) { valueToAdd /= 10; //Recover quicker. Reduce the length of time you'll be stunned for. UseMomentum(QUICK_RECOVER_MOMENTUM_COST); } stunnedTimer += valueToAdd; actionTimer = 0; //Wouldn't make sense to be put on cooldown from a move whilst you're on the ground. if (stunnedTimer > 300) //Don't allow wrestlers to be stunned for too long (but don't limit it entirely. doing so can ruin multi-man matches). { stunnedTimer = 300; } }
public SpecialMove GetSignature(PositionLayout requiredPosition) { if (signatures.ContainsKey(requiredPosition)) { List <SpecialMove> moveIDs = signatures [requiredPosition]; return(moveIDs [UsefulActions.RandomiseNumber(0, moveIDs.Count)]); } return(null); }
protected bool CanAvoidMove(float moveMaxChance, float avoidMaxChance) { float moveChance = UsefulActions.RandomiseNumber(0.0f, moveMaxChance); float avoidChance = UsefulActions.RandomiseNumber(0.0f, avoidMaxChance); avoidChance *= GetStaminaAsAPercentage(); //Lower chance to avoid if you have low stamina (not health, that will snowball too hard) avoidChance = (IsStunned()) ? avoidChance * 0.6f : avoidChance; //Lower chance to avoid if you're stunned return(moveChance < avoidChance); }
//Move without a destination public void MoveToAdjacentNode(Wrestler wrestler, NodeIndex start) { NodeIndex destination; do { destination = start + new NodeIndex((sbyte)UsefulActions.RandomiseNumber(-1, 2), (sbyte)UsefulActions.RandomiseNumber(-1, 2)); } while (!IsValidNode(destination)); MoveToAdjacentNode(wrestler, start, destination); }
protected bool CanUseSpecialMove(Wrestler attackingWrestler, Wrestler receivingWrestler, float bonusChance) { float attackerStamina = attackingWrestler.GetStaminaAsAPercentage(); float receiverHealth = receivingWrestler.GetHealthAsAPercentage(); float chance = 5 + receiverHealth * 20; chance -= (1 - attackerStamina) * 15; chance *= bonusChance; return(UsefulActions.RandomiseChance(chance)); }
//Mostly used to have wrestlers stay down for longer during multi-man matches, like in wrestling public virtual float StunnedMultiplier() { if (wrestlers.Length == 2) { return(1); } if (UsefulActions.RandomiseChance(wrestlers.Length * 5)) { return(2); } return(1); }
private static void AddToDictionary(string unparsedWrestlerString) { string key = UsefulActions.GetDataFromUnparsedFile(unparsedWrestlerString, "Name: "); WrestlerData wrestlerData = new WrestlerData(unparsedWrestlerString); if (allWrestlers.ContainsKey(key)) { throw new Exception("The wrestler '" + key + "' already exists."); } allWrestlers.Add(key, wrestlerData); }
private static void AddToDictionary(string unparsedMoveString) { string textFromFile = UsefulActions.GetDataFromUnparsedFile(unparsedMoveString, "ID: "); ushort moveID = ushort.Parse(textFromFile); //Remove the ID from the string MoveData newMove = new MoveData(unparsedMoveString); if (allMoves.ContainsKey(moveID)) { throw new Exception("The ID: " + moveID + " already exists."); } allMoves.Add(moveID, newMove); }
public void AddCooldown(float value) { float valueToAdd = value; //In real wrestling, wrestlers tend to perform slower as they take more damage and run out of breath. Due to that, that increases the cooldown float temp = UsefulActions.ClampValue(GetStaminaAsAPercentage()); valueToAdd *= (1 - temp) + 1; //Lower stamina leads to a longer cooldown temp = UsefulActions.ClampValue(GetHealthAsAPercentage()); valueToAdd *= (1 - temp) + 1; //Lower health also does //Add ambient action time depending on stamina, so the wrestler doesn't attack instantly, which doesn't always happen in wrestling. valueToAdd += UsefulActions.RandomiseNumber(0.1f, 6.0f - GetStaminaAsAPercentage() * 4.0f); actionTimer += valueToAdd; }
public MoveData GetRandomMove(PositionLayout requiredPosition) { List <MoveData> moves = null; if (favouriteMoves.ContainsKey(requiredPosition) && UsefulActions.RandomiseChance(80)) { moves = favouriteMoves [requiredPosition]; } if (normalMoves.ContainsKey(requiredPosition)) { moves = normalMoves [requiredPosition]; } if (moves == null || moves.Count == 0) { return(null); } return(moves [UsefulActions.RandomiseNumber(0, moves.Count)]); }
public static void Main(string[] args) { UsefulActions.InitialiseRandom(); MoveDictionary.Initialise(); WrestlerDictionary.Initialise(); Console.WriteLine("Welcome to my Wrestling Simulator!"); Console.WriteLine("Currently you can only do pin-fall only matches which require at least 2 wrestlers (can do multi-man matches)."); Console.WriteLine("\nHere's the list of all available wrestlers:"); WrestlerDictionary.ListAllWrestlers(); Console.WriteLine("\nList all wrestlers you wish to add into the match, then type START when you're done."); List <Wrestler> wrestlersInMatch = new List <Wrestler> (); string userInput = ""; while (!userInput.Equals("START")) { userInput = Console.ReadLine(); WrestlerData wrestlerDetails = WrestlerDictionary.GetWrestler(userInput); if (wrestlerDetails == null) { Console.WriteLine("The wrestler: '{0}' does not exist.", userInput); continue; } Wrestler wrestler = new Wrestler(wrestlerDetails); wrestlersInMatch.Add(wrestler); Console.WriteLine("{0} has been added.", userInput); } /*Wrestler wrestlerA = new Wrestler (WrestlerDictionary.GetWrestler ("Bob Dylan")); * Wrestler wrestlerB = new Wrestler (WrestlerDictionary.GetWrestler ("Jake Matthews")); * Wrestler wrestlerC = new Wrestler (WrestlerDictionary.GetWrestler ("Michael Lopez")); * Wrestler[] wrestlerList = new Wrestler[] { wrestlerA, wrestlerB, wrestlerC };*/ Match.instance = new NormalMatch(wrestlersInMatch.ToArray()); Match.instance.ProcessMatch(); Console.WriteLine("The program will end after you press enter."); Console.ReadLine(); }
public void ChangeTargetToSelection(Wrestler[] selectableWrestlers) { targettingWrestler = selectableWrestlers [0]; for (byte i = 1; i < selectableWrestlers.Length; i++) { byte chance = 20; if (selectableWrestlers [i].IsStunned()) { chance = 5; } if (selectableWrestlers [i].IsTargettingWrestler(this)) { chance = 50; } if (UsefulActions.RandomiseChance(chance)) { targettingWrestler = selectableWrestlers [i]; break; } } }
//Left public because in the future there may be match specific moves public MoveResult AttemptMove(Wrestler receivingWrestler, IMove move, float costMultiplier = 1) { float staminaCost = 0.4f * (byte)move.GetStaminaCost() * costMultiplier; float maxSuccessChance = myData.technique / staminaCost; //Without increasing this value, people with less technique than someone's counter stat can never ever land a move maxSuccessChance *= UsefulActions.ClampValue(GetStaminaAsAPercentage()) * 3; MoveData moveData = move.GetMove(); float damage = GetDamageByOffenceType(moveData) * staminaCost; damage = UsefulActions.RandomiseNumber(damage); ConsumeStamina(MOVE_BASE_STAMINA_COST * staminaCost); MoveResult result = receivingWrestler.ReceiveMove(maxSuccessChance, moveData, damage); receivingWrestler.ChangeTarget(this); //Without this, multi-man matches get kinda silly with someone getting beat up for free if (result == MoveResult.COUNTERED) { AddStun(receivingWrestler.GetCounterStunLength()); ChangePosition(moveData.reversalPosition); return(result); } if (result == MoveResult.NORMAL) { AddMomentum(MOVE_BASE_MOMENTUM_GAIN + damage / 50); //No charisma stat, simply made it so that wrestlers who hit harder gain more momentum } float moveTime = UsefulActions.RandomiseNumber(moveData.lowerMoveTime, moveData.upperMoveTime); //How long the move took AddCooldown(moveTime); receivingWrestler.AddStun(moveTime); return(result); }
public bool AttemptPinEscape(float chanceMultiplier) { float chance = GetHealthAsAPercentage() * myData.heart; //Wrestlers sometimes lose simply through being gassed, not through being beat up a lot. //There is a threshold so that the wrestler doesn't solely lose due to them being tired. It's just a factor. chance *= 0.25f + GetStaminaAsAPercentage() * 0.75f; //Multiplier below is used to help wrestlers kick out. Without it, wrestlers with low heart (i.e. 40) will never kickout, losing often in < 30 seconds chance *= PIN_MULTIPLIER * chanceMultiplier * Match.instance.GetRecoveryMultiplier(); //It can technically go over 100 at this point. That simply means you will kick out //Wrestlers stunned for longer (i.e. from a big move, or in this simulator, multiple moves) should have a lower chance of kicking out chance -= stunnedTimer / 10; bool kickedOut = UsefulActions.RandomiseChance(chance); if (kickedOut) { Output.AddToOutput(myData.name + " kicked out"); ReduceMaxHealth(); } return(kickedOut); }
public readonly float lowerMoveTime, upperMoveTime; //length of time it takes to perform the move public MoveData(string textToParse) { string textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Name: "); name = textFromFile; textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Description: "); description = textFromFile; textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina Cost: "); switch (textFromFile.ToUpper()) { case "VERY LOW": staminaCost = StaminaCost.VERY_LOW; break; case "LOW": staminaCost = StaminaCost.LOW; break; case "NORMAL": staminaCost = StaminaCost.NORMAL; break; case "HIGH": staminaCost = StaminaCost.HIGH; break; case "VERY HIGH": staminaCost = StaminaCost.VERY_HIGH; break; } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Offence Type: "); switch (textFromFile.ToUpper()) { case "GRAPPLE": offenceType = OffenceType.GRAPPLE; break; case "STRIKE": offenceType = OffenceType.STRIKE; break; case "DIVE": offenceType = OffenceType.FLYING; break; case "RUNNING": offenceType = OffenceType.RUNNING; break; } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Position: "); requiredPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Opponent Position: "); requiredOpponentPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Finished Position: "); finishedPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Reversal Position: "); reversalPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Damaged Body Parts: "); string[] bodyParts = textFromFile.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); damagedBodyParts = new BodyPart[bodyParts.Length]; for (byte i = 0; i < bodyParts.Length; i++) { switch (bodyParts [i].ToUpper()) { case "HEAD": damagedBodyParts [i] = BodyPart.HEAD; break; case "TORSO": damagedBodyParts [i] = BodyPart.TORSO; break; case "ARMS": damagedBodyParts [i] = BodyPart.ARMS; break; case "LEGS": damagedBodyParts [i] = BodyPart.LEGS; break; default: throw new Exception("Not a valid body part."); } } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Lower Move Time: "); lowerMoveTime = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Upper Move Time: "); upperMoveTime = float.Parse(textFromFile); }
public WrestlerData(string textToParse) { /*string textToParse = File.ReadAllText (filePath); * if (textToParse.Length == 0) * throw new Exception ("File with path '" + filePath + "' is empty.");*/ string textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Name: "); name = textFromFile; textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Wrestling Style: "); wrestlingStyle = GetWrestlingStyle(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Weight: "); weight = ushort.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Grapple Strength: "); grappleStrength = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Striking Strength: "); strikingStrength = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Running Strength: "); runningStrength = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Diving Strength: "); divingStrength = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Heart: "); heart = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Health: "); health = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Health Recovery: "); healthRecovery = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina: "); stamina = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina Recovery: "); staminaRecovery = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Head Resistance: "); headResistance = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Torso Resistance: "); torsoResistance = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Arms Resistance: "); armResistance = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Legs Resistance: "); legResistance = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Technique: "); technique = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Speed: "); speed = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Block: "); block = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Counter: "); counter = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Submission: "); submission = float.Parse(textFromFile); myMoves = new MoveList(); //Add moves to the moves list textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Finishers: "); while (textFromFile.Length > 1) { int indexOfComma = textFromFile.IndexOf(','); int indexOfIDStart = indexOfComma + 2; int indexOfEnd = textFromFile.IndexOf(']'); string specialMoveName = textFromFile.Substring(1, indexOfComma - 1); string moveIDText = textFromFile.Substring(indexOfIDStart, indexOfEnd - indexOfIDStart); ushort moveID = ushort.Parse(moveIDText); MoveData originalMove = MoveDictionary.GetMove(moveID); PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition); myMoves.AddToFinishers(requiredPosition, moveID, specialMoveName); textFromFile = textFromFile.Remove(0, indexOfEnd + 1); if (textFromFile.Length != 0) { textFromFile = textFromFile.Remove(0, 2); } } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Signatures: "); while (textFromFile.Length > 1) { int indexOfComma = textFromFile.IndexOf(','); int indexOfIDStart = indexOfComma + 2; int indexOfEnd = textFromFile.IndexOf(']'); string specialMoveName = textFromFile.Substring(1, indexOfComma - 1); string moveIDText = textFromFile.Substring(indexOfIDStart, indexOfEnd - indexOfIDStart); ushort moveID = ushort.Parse(moveIDText); MoveData originalMove = MoveDictionary.GetMove(moveID); PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition); myMoves.AddToSignatures(requiredPosition, moveID, specialMoveName); textFromFile = textFromFile.Remove(0, indexOfEnd + 1); if (textFromFile.Length != 0) { textFromFile = textFromFile.Remove(0, 2); } } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Favourite Moves: "); while (textFromFile.Length > 1) { int indexOfComma = textFromFile.IndexOf(','); if (indexOfComma == -1) { indexOfComma = textFromFile.Length - 1; } string moveIDText = textFromFile.Substring(0, indexOfComma); ushort moveID = ushort.Parse(moveIDText); MoveData originalMove = MoveDictionary.GetMove(moveID); PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition); myMoves.AddToFavouriteMoves(requiredPosition, moveID); if (indexOfComma + 2 > textFromFile.Length) { break; } textFromFile = textFromFile.Remove(0, indexOfComma + 2); } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Normal Moves: "); while (textFromFile.Length > 1) { int indexOfComma = textFromFile.IndexOf(','); if (indexOfComma == -1) { indexOfComma = textFromFile.Length - 1; } string moveIDText = textFromFile.Substring(0, indexOfComma); ushort moveID = ushort.Parse(moveIDText); MoveData originalMove = MoveDictionary.GetMove(moveID); PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition); myMoves.AddToMoves(requiredPosition, moveID); if (indexOfComma + 2 > textFromFile.Length) { break; } textFromFile = textFromFile.Remove(0, indexOfComma + 2); } }
//This will be more complex in the future. It's mostly set like this right now to show that it all works. public override void MatchStep() { //Output.AddToOutput (elapsedTime.ToString()); Wrestler attackingWrestler = GetNextActiveWrestler(); Wrestler receivingWrestler = attackingWrestler.GetTargettingWrestler(); float pinMultiplier = 4; //In multiman matches, randomly change targets if your target is stunned if (wrestlers.Length > 2 && receivingWrestler.IsStunned() && UsefulActions.RandomiseChance(25)) { Wrestler[] otherWrestlers = GetOtherWrestlers(attackingWrestler).ToArray(); attackingWrestler.ChangeTargetToSelection(otherWrestlers); } if (attackingWrestler.GetPosition() != WrestlerPosition.STANDING) { if (attackingWrestler.GetPosition() == WrestlerPosition.GROUNDED) { ChangePosition(attackingWrestler, WrestlerPosition.GROGGY); } else { ChangePosition(attackingWrestler, WrestlerPosition.STANDING); } return; } IMove attackToUse = null; MoveType moveType = MoveType.NORMAL; if (CanUseFinisher(attackingWrestler, receivingWrestler)) { attackToUse = attackingWrestler.GetFinisher(); moveType = MoveType.FINISHER; pinMultiplier = 0.5f; } else if (CanUseSignature(attackingWrestler, receivingWrestler)) { attackToUse = attackingWrestler.GetSignature(); moveType = MoveType.SIGNATURE; pinMultiplier = 1; } else if (CanUseMove(attackingWrestler, receivingWrestler)) { attackToUse = attackingWrestler.GetMove(); moveType = MoveType.NORMAL; pinMultiplier = 2; } if (attackToUse != null) { MoveResult moveResult = AttemptMove(attackingWrestler, receivingWrestler, attackToUse, moveType); if (moveResult != MoveResult.NORMAL) //Stop the turn immediately if our move didn't go through { return; } } if (attackingWrestler.IsStunned()) //If the wrestler collapsed by any chance { return; } if (receivingWrestler.GetPosition() == WrestlerPosition.GROUNDED) { if (UsefulActions.RandomiseChance(49.0f / pinMultiplier) && attackToUse != null || UsefulActions.RandomiseChance(10)) { PinAttempt(attackingWrestler, receivingWrestler, pinMultiplier); return; } if (UsefulActions.RandomiseChance(40)) { ChangeReceiverPosition(attackingWrestler, receivingWrestler, WrestlerPosition.GROGGY); return; } } }