forked from Reddit-Mud/RMUD
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHit.cs
58 lines (51 loc) · 2.47 KB
/
Hit.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RMUD;
namespace Space
{
internal class Hit : CommandFactory
{
public override void Create(CommandParser Parser)
{
Parser.AddCommand(
BestScore("OBJEcT",
Sequence(
Or(
KeyWord("HIT"),
KeyWord("ATTACK"),
KeyWord("SMASH"),
KeyWord("BREAK")),
MustMatch("@not here",
Object("SUBJECT", InScope)),
OptionalKeyWord("WITH"),
MustMatch("@not here",
Object("OBJECT", InScope, PreferHeld)))))
.Manual("Hit an object with another object.")
.Check("can hit with?", "ACTOR", "SUBJECT", "OBJECT")
.BeforeActing()
.Perform("hit with", "ACTOR", "SUBJECT", "OBJECT")
.AfterActing();
}
public static void AtStartup(RuleEngine GlobalRules)
{
GlobalRules.DeclareCheckRuleBook<MudObject, MudObject, MudObject>("can hit with?", "[Actor, Subject, Object] : Can the SUBJECT be hit by the ACTOR with the OBJECT?");
GlobalRules.Check<MudObject, MudObject, MudObject>("can hit with?")
.Do((actor, subject, @object) => MudObject.CheckIsVisibleTo(actor, subject))
.Name("Item must be visible to hit it.");
GlobalRules.Check<MudObject, MudObject, MudObject>("can hit with?")
.Do((actor, subject, @object) => MudObject.CheckIsHolding(actor, @object))
.Name("Object must be held rule.");
GlobalRules.Check<MudObject, MudObject, MudObject>("can hit with?")
.Do((a, b, c) => SharpRuleEngine.CheckResult.Allow)
.Name("Default allow hitting rule.");
GlobalRules.DeclarePerformRuleBook<MudObject, MudObject, MudObject>("hit with", "[Actor, Subject, Object] : Handle the actor hitting the subject with the object.");
GlobalRules.Perform<MudObject, MudObject, MudObject>("hit with").Do((actor, subject, @object) =>
{
MudObject.SendMessage(actor, "I smacked <the0> with <the1>. I don't think it did anything.", subject, @object);
return SharpRuleEngine.PerformResult.Stop;
});
}
}
}