Skip to content
Permalink
Browse files

Game - add 'insert coin' functionality

  • Loading branch information...
bobbymcr committed Dec 22, 2018
1 parent cb3b525 commit 8b5b7c118b66608d9385810f1f1b3e0f4e3a765d
Showing with 34 additions and 1 deletion.
  1. +2 −0 core/src/Item.cs
  2. +19 −0 sample/src/Coin.cs
  3. +2 −1 sample/src/Verb.cs
  4. +5 −0 sample/test/walkthrough.quit.in
  5. +6 −0 sample/test/walkthrough.quit.out
@@ -49,5 +49,7 @@ public bool Drop()
protected void Output(string text) => this.Bus.Output(text);

protected void SendRoom(Action<Room> act) => this.Bus.Send(new ActionMessage<Room>(act));

protected void SendInventory(Action<Inventory> act) => this.Bus.Send(new ActionMessage<Inventory>(act));
}
}
@@ -23,6 +23,12 @@ protected override bool DoCore(Word verb, Word noun)
return true;
}

if (verb.Primary == Verb.Insert)
{
this.Insert(noun);
return true;
}

return base.DoCore(verb, noun);
}

@@ -37,5 +43,18 @@ private void Read()
this.Output("The writing is too small. You'd have to pick it up to see it better.");
}
}

private void Insert(Word noun)
{
if (this.Taken)
{
this.Output("You insert the coin into the hole. Nothing happens.");
this.SendInventory(i => i.Remove(noun.Primary));
}
else
{
this.Output("You'll have to get it first.");
}
}
}
}
@@ -11,12 +11,13 @@ internal sealed class Verb
public static readonly Verb Drop = new Verb("drop", "throw");
public static readonly Verb Go = new Verb("go");
public static readonly Verb Greet = new Verb("greet", "hello", "hi");
public static readonly Verb Insert = new Verb("insert");
public static readonly Verb Inventory = new Verb("inventory", "inv");
public static readonly Verb Look = new Verb("look");
public static readonly Verb Move = new Verb("move");
public static readonly Verb Take = new Verb("take", "get");
public static readonly Verb Quit = new Verb("quit", "exit");
public static readonly Verb Read = new Verb("read");
public static readonly Verb Take = new Verb("take", "get");

private readonly string verb;
private readonly string[] synonyms;
@@ -30,5 +30,10 @@ look coin
go forth
go east
look wall
drop coin
insert coin
get coin
insert coin
inv
exit
-- END --
@@ -37,4 +37,10 @@ a coin
> You can't go that way.
> You are in the auxiliary room. There is a hole in the wall. There is a doorway to the west. There is a cliff to the east.
> Above the hole you see the words, "INSERT COIN."
> You drop the coin.
> You'll have to get it first.
> You get the coin.
> You insert the coin into the hole. Nothing happens.
> You are carrying:
(nothing)
>

0 comments on commit 8b5b7c1

Please sign in to comment.
You can’t perform that action at this time.