More change methods

- Merge LimitToRange() extension method into other static values
- Added social motive to printing of motive values
This commit is contained in:
Anthony Leland 2020-10-28 21:09:46 -04:00
parent 731cf826fd
commit 373170f98e

View file

@ -37,16 +37,9 @@
"source": [ "source": [
"static Random rng = new Random();\n", "static Random rng = new Random();\n",
"static int MaxMood = 60;\n", "static int MaxMood = 60;\n",
"static int MaxMotive = 10;" "static int MaxMotive = 10;\n",
], "\n",
"outputs": [] "static int LimitToRange(this int val, int min, int max)\n",
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"public static int LimitToRange(this int val, int min, int max)\n",
"{\n", "{\n",
" if (val < min) { return min; }\n", " if (val < min) { return min; }\n",
" if (val > max) { return max; }\n", " if (val > max) { return max; }\n",
@ -130,6 +123,16 @@
" {\n", " {\n",
" Fun = CalcuateMotiveChange(Fun, input);\n", " Fun = CalcuateMotiveChange(Fun, input);\n",
" }\n", " }\n",
"\n",
" public void ChangeBladder(int input)\n",
" {\n",
" Bladder = CalcuateMotiveChange(Bladder, input);\n",
" }\n",
"\n",
" public void ChangeSocial(int input)\n",
" {\n",
" Social = CalcuateMotiveChange(Social, input);\n",
" }\n",
"}" "}"
], ],
"outputs": [] "outputs": []
@ -149,6 +152,7 @@
"Console.WriteLine($\"Hunger: {motives.Hunger}{Environment.NewLine}\" +\n", "Console.WriteLine($\"Hunger: {motives.Hunger}{Environment.NewLine}\" +\n",
" $\"Fun: {motives.Fun}{Environment.NewLine}\" +\n", " $\"Fun: {motives.Fun}{Environment.NewLine}\" +\n",
" $\"Bladder: {motives.Bladder}{Environment.NewLine}\" +\n", " $\"Bladder: {motives.Bladder}{Environment.NewLine}\" +\n",
" $\"Social: {motives.Social}{Environment.NewLine}\" +\n",
" $\"Environment: {motives.Environment}\");\n", " $\"Environment: {motives.Environment}\");\n",
"Console.WriteLine($\"Mood: {motives.Mood}\");" "Console.WriteLine($\"Mood: {motives.Mood}\");"
], ],
@ -161,8 +165,12 @@
"source": [ "source": [
"motives.ChangeHunger(rng.Next(MaxMotive));\n", "motives.ChangeHunger(rng.Next(MaxMotive));\n",
"motives.ChangeFun(rng.Next(MaxMotive));\n", "motives.ChangeFun(rng.Next(MaxMotive));\n",
"motives.ChangeSocial(rng.Next(MaxMotive));\n",
"motives.ChangeBladder(rng.Next(MaxMotive));\n",
"Console.WriteLine($\"New Hunger: {motives.Hunger}{Environment.NewLine}\" +\n", "Console.WriteLine($\"New Hunger: {motives.Hunger}{Environment.NewLine}\" +\n",
" $\"New Fun: {motives.Fun}\");\n", " $\"New Fun: {motives.Fun}{Environment.NewLine}\" +\n",
" $\"New Bladder: {motives.Bladder}{Environment.NewLine}\" +\n",
" $\"New Social: {motives.Social}\");\n",
"Console.WriteLine($\"New Mood: {motives.Mood}\");" "Console.WriteLine($\"New Mood: {motives.Mood}\");"
], ],
"outputs": [] "outputs": []