Skip to content

Commit 0d94822

Browse files
committed
Merge pull request #2 from kiwiyou/patch-2
Add "random" operator
2 parents 7c7d201 + 69deccf commit 0d94822

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

ClickWar2/Game/CommandOperator.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Drawing;
88
using ClickWar2.Game.Network.ServerWorker;
9+
using ClickWar2.Game.Utility.Random;
910

1011
namespace ClickWar2.Game
1112
{
@@ -558,6 +559,26 @@ public CommandOperator()
558559
return 1;
559560
});
560561
SetWork("to integer", "int");
562+
563+
SetWork("random", 2, (boardDirector, userDirector, chip, param, hereTile, herePose) =>
564+
{
565+
if (!IsInt(param[1]))
566+
return 1;
567+
568+
// 아마도 ArrayIndexBoundsOfException
569+
// if문으로 안한 이유는 귀찮아서입니다.
570+
try {
571+
if (!IsInt(param[2]))
572+
return 1;
573+
574+
this.SetVar(param[0], Random.Next(ToInt(param[1]), ToInt(param[2])));
575+
} catch {
576+
this.SetVar(param[0], Random.Next(ToInt(param[1])));
577+
} finally {
578+
return 1;
579+
}
580+
});
581+
SetWork("random", "rnd");
561582
}
562583

563584
//#####################################################################################

0 commit comments

Comments
 (0)