public static Actor CreateRandomActor() { RPGCalc calc = new RPGCalc(); int primary = calc.Roll(6); int secondary = calc.Roll(6); while (primary == secondary) { secondary = calc.Roll(6); } return(CreateRandomActor((Attribute)Enum.Parse(typeof(Attribute), primary.ToString()), (Attribute)Enum.Parse(typeof(Attribute), secondary.ToString()))); }
public static RPGSpellBook CreateRandomSpellbook() { RPGCalc calc = new RPGCalc(); int size = calc.Roll(DEFAULT_MAX_SPELL_COUNT * 2); RPGSpellBook book = new RPGSpellBook(size); int count = calc.Roll(size); for (int i = 0; i < count; i++) { book.AddSpell(RPGSpell.CreateRandomSpell()); } return(book); }
public static RPGEffect CreateRandomSpellEffect() { #region Setup Vars RPGCalc calc = new RPGCalc(); DurationType t = DurationType.Permanent; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff = EffectTargetBuff.RestoreHP; EffectTargetAttack targetAttack = EffectTargetAttack.DoMagicalDamage; bool isBuff = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; bool reverse = true; #endregion #region Buff or Attack // 50/50 percent of offensive for completely random if (calc.Roll(2) == 1) { isBuff = true; } else { isBuff = false; } #endregion #region Range and Distance // check to avoid attacking self while (!isBuff && r == EffectRange.Self) { r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); } // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch #endregion #region Attack and Buff Effects // target buff effect targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); // target attack effect // 20% chance of being completely random if (calc.Roll(10) >= 8) { targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); } else // 80% chance of being magical damage { targetAttack = EffectTargetAttack.DoMagicalDamage; } #endregion #region Set Duration Types based on effect // isBuff and is restore, or isNotBuff and is Dmg if (isBuff) { // then we want to reverse all but the restore if (targetBuff == EffectTargetBuff.RestoreHP || targetBuff == EffectTargetBuff.RestoreMP) { reverse = false; t = DurationType.Permanent; } else { reverse = true; duration = calc.RollRandomEffectDuration(0, 0, 0, 60); t = DurationType.ForTime; } } else // it's an attack { // check to avoid reverse on dmg spells if (targetAttack == EffectTargetAttack.DoMagicalDamage || targetAttack == EffectTargetAttack.DoPhysicalDamage) { reverse = false; t = DurationType.Permanent; } else { reverse = true; duration = calc.RollRandomEffectDuration(0, 0, 0, 60); t = DurationType.ForTime; } } #endregion #region Power // roll for min/max power - start with generic minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // NOTE: dmg depends on duration and duration type - if long, then small dmg... #endregion #region Trigger // trigger - spell will cause effect immediately. trigger = EffectTrigger.Immediately; #endregion RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomPotionEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.ForTime; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = EffectRange.Touch; EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff = EffectTargetBuff.RestoreHP; EffectTargetAttack targetAttack = EffectTargetAttack.DoPhysicalDamage; bool isBuff = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; bool reverse = true; // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); if (targetBuff == EffectTargetBuff.RestoreHP || targetBuff == EffectTargetBuff.RestoreMP) { reverse = false; } else { duration = calc.RollRandomEffectDuration(); } // roll for range while (r == EffectRange.Touch) { r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); } // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // trigger - potion will cause effect to be used immediately. trigger = EffectTrigger.Immediately; RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomWeaponEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.WhileEquipped; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r; EffectTrigger trigger = EffectTrigger.onAttackLanded; EffectTargetBuff targetBuff; EffectTargetAttack targetAttack; bool isBuff = false; bool reverse = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; // roll for range r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); // roll for distance depending on range switch (r) { case (EffectRange.Self): { isBuff = true; break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // roll for trigger while (trigger == EffectTrigger.onUse || trigger == EffectTrigger.onHit) { trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger)); } RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.ForTime; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = EffectRange.Target; EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff; EffectTargetAttack targetAttack; bool isBuff = true; bool reverse = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; // roll for type t = (DurationType)calc.GetRandomEnum(typeof(DurationType)); duration = new TimeSpan(0); if (t == DurationType.ForTime) { duration = calc.RollRandomEffectDuration(); // ticks (I think) } // roll for range r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); isBuff = (calc.Roll(2) == 1); // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // roll for trigger trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger)); RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }