AdvancedDiceAndCoins 1.1.1
See the version list below for details.
dotnet add package AdvancedDiceAndCoins --version 1.1.1
NuGet\Install-Package AdvancedDiceAndCoins -Version 1.1.1
<PackageReference Include="AdvancedDiceAndCoins" Version="1.1.1" />
paket add AdvancedDiceAndCoins --version 1.1.1
#r "nuget: AdvancedDiceAndCoins, 1.1.1"
// Install AdvancedDiceAndCoins as a Cake Addin #addin nuget:?package=AdvancedDiceAndCoins&version=1.1.1 // Install AdvancedDiceAndCoins as a Cake Tool #tool nuget:?package=AdvancedDiceAndCoins&version=1.1.1
AdvancedDiceAndCoins
Proudly* presenting my first package, designed for simulating all kinds of dice rolls. My friends and family have told me it’s great! Give it a roll! (sorry) Your feedback is welcome. (appreciate gentle ones)
Usage/Examples
using AdvancedDiceAndCoins;
//Easiest way to imitate a Roll:
int attack = Roll.D20; //D4, D6, D8, D10, D12, D100 supported as well
int attackAgainstProne = Roll.D20WithAdvantage; //Roll.D20WithDisadvantage supported
//Dice class - How to initialize - IMPORTANT only 1 dice...
//So for 2D6 => create 2 dice or use DiceSet, or create a D6 and use RollOfMany() method.
//LastRoll is 0, until first Roll();
Dice swordDamage = new("D8+2"); //D8 + 2
Dice maceDamage = new(6); //D6
Dice player1Attack = new(20, 8); // numberOfSides, modifier => D20 + 8
Dice daggerOfMinimumTwoDamage = new(2, 6, 0); //smallestNumber, largestNumber, modifier
//valid strings: new("d6"), new("d12 + 3"), new("D20-2") etc.
//Dice class - How to use it?
int orcHP = 20;
orcHP -= swordDamage.Roll();
//available methods: Roll(), RollOfAdvantage(), RollOfDisadvantage(), RollOfMany()
//properties: LastRoll => you can check the result of last Roll() or RollOfAdvantage()...
//Dice class - RollOfMany()
int maceDamageThreeTimes = maceDamage.RollOfMany(3); // Rolls: 4 + 3 + 2 return 9,
// but IMPORTANT LastRoll will be 2!
//Dice class - ToString()
Console.WriteLine(swordDamage); //=> D8 + 2
//Misc
Dice a = new(6);
Dice b = new(6);
a.Roll();
b.Roll();
int result = a + b; //a.LastRoll + b.LastRoll
if (a - b > 0)
{
Console.WriteLine("*: should be more modest");
}
if (a == b) //a.LastRoll == b.LastRoll
{
a.Roll();
}
//Dice class Equals => if smallest number, largest number, modifiers are equals!
//D6 != D6 + 2; D8 + 7 == D8 + 7;
//DiceSet class the purpose of the class to contain more (even mixed) dice
//and able to roll them at once
//How to initialize
DiceSet diceSet = new();
diceSet.Add(swordDamage);
diceSet.Add(maceDamage); //=> diceSet is now: D8 + 2 + D6;
DiceSet redDragonBreath = new("18D6");
//valid strings: new("6d6"), new("4d12 + 3"), new("2D20-2") etc.
//if modifier provided eg. 3D6+5 => D6, D6, D6+5 will be created.
Dice smokeDamage = new(4);
redDragonBreath.Add(smokeDamage) // it is now 18D6 + D4 (just in case)
//How to use
int playerHP = 20;
playerHP -= redDragonBreath.Roll();
int swordPlusMaceDamage = diceSet.Roll(); //=> Roll with D8+2+D6;
//available method: Roll(), Clear()
//properties: LastRoll where the result of last Roll() is stored, by default it's 0.
//You can add DiceSets
DiceSet whiteDragonBreath = new("12D8");
DiceSet notYourLuckyDay = redDragonBreath + whiteDragonBreath;
//new DiceSet with 18D6 + 12D8 + D4 (almost forgot the smokedamage)
//You can check your DiceSet
Console.WriteLine(notYourLuckyDay); //=> D6, D6, D6 ... D8, D8, D8, ... D4
//You can Clear() a DiceSet removing all Dice from it. Important! LastRoll remains unchanged.
//Coin class
Coin coin = new();
coin.Flip(); // returns with a string Heads or Tails (same as Flip())
coin.Toss(); // returns with a string Heads or Tails (same as Toss())
Console.WriteLine(coin.NumberOfTails);
//properties: NumberOfTails, NumberOfHeads ... for statistical purposes.
Console.WriteLine(coin); // a Flip() is made. ((returns Heads or Tails))
//LeftOrRight / TrueOrFalse Class
Console.WriteLine(LeftOrRight.Decide()) //=> returns Left / Right
Console.WriteLine(TrueOrFalse.Decide()) //=> returns bool true / false
Roadmap
Update coin class. (you can make your own decisions, instead Head or Tails only) Collecting and evaluating Roll() statistics. (avarage, mode, median etc.)
Authors
Feedback
If you have any feedback, please reach out at ifigazsisp@gmail.com
License
MIT License
Copyright (c) 2024, Zoltán Kapeller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Major Readme File update.
Dice Class:
RollWithAdvantage / Disadvantage introduced.
RollOfMany introduced.
DiceSet Class:
You can now add DiceSet-s together.
Clear method