Skip to content

Commit

Permalink
Merge pull request #1 from inaka/elbrujohalcon.1.make_it_open_source_…
Browse files Browse the repository at this point in the history
…able

Make it open-source-able
  • Loading branch information
igaray committed Jun 9, 2015
2 parents 3fdc479 + eae20f9 commit 5e7420f
Show file tree
Hide file tree
Showing 13 changed files with 1,617 additions and 422 deletions.
5 changes: 2 additions & 3 deletions LICENSE
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2015 Electronic Inaka LLC
Copyright 2015 Erlang Solutions Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

4 changes: 2 additions & 2 deletions Makefile
@@ -1,6 +1,6 @@
PROJECT = gold_fever

CONFIG ?= test/test.config
CONFIG ?= config/generic.config
NODEIP ?= 127.0.0.1

RELX_URL := https://github.com/erlware/relx/releases/download/v2.0.0/relx
Expand All @@ -11,7 +11,7 @@ TEST_DEPS = xref_runner

dep_katana = git https://github.com/inaka/erlang-katana.git 0.2.5
dep_eper = git https://github.com/massemanet/eper.git 0.90.0
dep_shotgun = git https://github.com/inaka/shotgun.git 0.1.8
dep_shotgun = git https://github.com/inaka/shotgun.git 0.1.11
dep_sync = git https://github.com/inaka/sync.git 0.1
dep_xref_runner = git https://github.com/inaka/xref_runner.git 0.2.2

Expand Down
42 changes: 41 additions & 1 deletion README.md
@@ -1,2 +1,42 @@
# gold_fever
# Gold Fever
A Treasure Hunt for Erlangers

## Introduction
This repo provides the server for a distributed treasure hunt game using erlang nodes.
It was originally used for Inaka's Erlang Dojo 2015, but it can hopefully be used by anyone :)

## Instructions
To run the server just clone the repo and start the app in shell:

```bash
git clone https://github.com/inaka/gold_fever.git
cd gold_fever
make && make shell
```

Then let the players connect to it by giving them your node name and cookie (as a bonus you can give them a *clue* to get the cookie instead).

## Configuration
The different game stages are configured by application environment. To help you with that a [sys.config.template](config/sys.config.template) is provided, along with the configuration we used at [inaka](config/inaka.config) and the [generic](config/generic.config) one that's used by default.
If you want to start the server using your own config, just do:

```bash
CONFIG="path/to/your.config" make shell
```

You can also set the IP part of your node name by doing:

```bash
NODEIP=192.168.48.33 make shell
```

## Contact Us
For **questions** or **general comments** regarding the use of this project,
please use our public [hipchat room](https://www.hipchat.com/gpBpW3SsT).

If you find any **bugs** or have a **problem** while using this project, please
[open an issue](https://github.com/inaka/shotgun/issues/new) in this repo
(or a pull request :)).

And you can check all of our open-source projects at
[inaka.github.io](http://inaka.github.io)
94 changes: 94 additions & 0 deletions config/generic.config
@@ -0,0 +1,94 @@
[
{lager,
[
{colored, true},
{async_threshold, 200},
{async_threshold_window, 5},
{error_logger_hwm, 500},
{handlers, [{lager_console_backend, [debug, true]}]}
]
},
{sasl,
[
{sasl_error_logger, false},
{errlog_type, error}
]
},
{gold_fever,
[ {step1, #{ cookie => 'erlang-dojo-2015'
, message => "Welcome to the far west, fellow!"
"\nNow spawn 'larry' and listen to me."
"\nI have something for you..."
}}
, {step2, #{ message => "Keep the token, now send a flower to Kathy "
"she will help you find that thief..."
, unexpected => "I'm expecting flowers, my dear. "
"~p is not a flower -L-\n"
}}
, {step3, #{ message => "Oh! Nice flower, dear... I love flowers!\n"
"I also love maps and Larry told me you have a fancy"
"\ngen_server over there. Send me a map that will"
"\nguide me to it and don't forget to add the token"
"\ngiven to Larry before, that way I will be sure"
"\nit's really you"
, missing => "You didn't send me the '~p' of your gen_server :("
, badauth => "Who *are* you?!~i"
, unexpected => "I'm expecting maps, my dear.\n"
"~p\nis not a map -L-\n"
}}
, {step4, #{ message => "Hurry up, I fear someone is watching me. "
"Please, please kill him!!"
}}
, {step5, #{ message => "You might have killed me but my people will avenge "
"my death. BRACE YOURSELF... YOU'LL BE EXTERMINATED!"
, reason => "If you can read this, then Kathy is free. "
"Beware of her, she is not a lady: she's an FSM. "
"I bet you sent her flowers, try asking her about "
"their color a couple of times"
}}
, {step6, #{ answers => [red, pink, blue, white, orange]
, message => "You've got me... I'm just a machine, but I'll "
"never tell you where the real 'kathy' is!! "
"You won't be able to call her!"
, regexes => [<<"color">>, <<"flower">>]
, missing => "Will you ask me a '~p'?"
, unknown => "I don't know the answer to that. "
"Ask me something else"
, badauth => "I'm not talking to you!~i"
, unexpected => "I'm expecting maps, my dear.\n"
"~p\nis not a map -L-\n"
}}
, {step7, #{ welcome => "Aw, thanks! you found me!!"
, again => "Hey again!"
, message => "Now I know you're with me. But are you a real "
"cowboy? If so, cast me a map with your address and "
"your token and I'll PUT something in your pocket "
"to help you find the thief"
, expired => "I'm not talking to you anymore!"
, badauth => "Please send me your token, I need to know that "
"you are on my side"
}}
, {step8, #{ image => "priv/joe.png"
, path => "pocket"
, headers => #{<<"content-type">> => <<"image/png">>}
, message => "Do you know him? Find his node! He hid his treasure"
" there. The treasure must be in his 'vault'"
, missing => "I still need '~p' :)"
, toosoon => "Too soon, my dear... don't you think you should "
"give me a call first?"
, badauth => "Please send me your token, I need to know that "
"it is you"
, notaurl => "I don't know how to get to that address, sorry :/"
}}
, {step9, #{ nodename => joe
, attempts => 5
, passwords => [letitcrash, "let it crash"]
, warning => "Vault locked, enter the key"
, rickroll => "http://ow.ly/NQkbK"
, unlocked => "Vault unlocked, ask for contents"
, wrongpwd => "Wrong key@, try again~i"
, treasure => "http://ow.ly/NQmoH"
}}
]
}
].
94 changes: 94 additions & 0 deletions config/inaka.config
@@ -0,0 +1,94 @@
[
{lager,
[
{colored, true},
{async_threshold, 200},
{async_threshold_window, 5},
{error_logger_hwm, 500},
{handlers, [{lager_console_backend, [debug, true]}]}
]
},
{sasl,
[
{sasl_error_logger, false},
{errlog_type, error}
]
},
{gold_fever,
[ {step1, #{ cookie => 'erlang-dojo-2015'
, message => "Welcome to the far west, fellow!"
"\nNow spawn 'larry' and listen to me."
"\nI have something for you..."
}}
, {step2, #{ message => "Keep the token, now send a flower to Kathy "
"she will help you find that thief..."
, unexpected => "I'm expecting flowers, my dear. "
"~p is not a flower -L-\n"
}}
, {step3, #{ message => "Oh! Nice flower, dear... I love flowers!\n"
"I also love maps and Larry told me you have a fancy"
"\ngen_server over there. Send me a map that will"
"\nguide me to it and don't forget to add the token"
"\ngiven to Larry before, that way I will be sure"
"\nit's really you"
, missing => "You didn't send me the '~p' of your gen_server :("
, badauth => "Who *are* you?!~i"
, unexpected => "I'm expecting maps, my dear. "
"~p is not a map -L-\n"
}}
, {step4, #{ message => "Hurry up, I fear someone is watching me. "
"Please, please kill him!!!"
}}
, {step5, #{ message => "You might have killed me but my people will avenge "
"my death. BRACE YOURSELF... YOU'LL BE EXTERMINATED!"
, reason => "If you can read this, then Kathy is free. "
"Beware of her, she is not a lady: she's an FSM. "
"I bet you sent her flowers, try asking her about "
"their color a couple of times"
}}
, {step6, #{ answers => [red, pink, blue, white]
, message => "You've got me... I'm just a machine, but I'll "
"never tell you where the real 'kathy' is!! "
"You won't be able to call her!"
, regexes => [<<"color">>, <<"flower">>]
, missing => "Will you ask me a '~p'?"
, unknown => "I don't know the answer to that. "
"Ask me something else"
, badauth => "I'm not talking to you!~i"
, unexpected => "I'm expecting maps, my dear. "
"~p is not a map -L-\n"
}}
, {step7, #{ welcome => "Aw, thanks! you found me!!"
, again => "Hey again!"
, message => "Now I know you're with me. But are you a real "
"cowboy? If so, cast me a map with your address and "
"your token and I'll PUT something in your pocket "
"to help you find the thief"
, expired => "I'm not talking to you anymore!"
, badauth => "Please send me your token, I need to know that "
"you are on my side"
}}
, {step8, #{ image => "priv/thief.png"
, path => "pocket"
, headers => #{<<"content-type">> => <<"image/png">>}
, message => "Do you know him? Find his node! He hid his treasure"
" there. The treasure must be in his 'vault'"
, missing => "I still need '~p' :)"
, toosoon => "Too soon, my dear... don't you think you should "
"give me a call first?"
, badauth => "Please send me your token, I need to know that "
"it is you"
, notaurl => "I don't know how to find that address, sorry :/"
}}
, {step9, #{ nodename => inako
, attempts => 5
, passwords => [nuestraclave, "nuestraclave"]
, warning => "Vault locked"
, rickroll => "http://ow.ly/NQkbK"
, unlocked => "Vault unlocked, ask for contents"
, wrongpwd => "Wrong password, try again~i"
, treasure => "http://ow.ly/NQmoH"
}}
]
}
].
3 changes: 2 additions & 1 deletion config/sys.config.template
Expand Up @@ -40,6 +40,7 @@
, unexpected => "a message with ~p"
}}
, {step7, #{ welcome => "a welcoming message"
, again => "a re-welcoming message"
, message => "da message"
, expired => "an error message"
, badauth => "an error message"
Expand All @@ -55,7 +56,7 @@
}}
, {step9, #{ nodename => 'a-node-name'
, attempts => 5
, password => 'a-password'
, passwords => [a, "list", <<"of valid passwords">>]
, warning => "a warning message"
, rickroll => "a link"
, unlocked => "a message"
Expand Down
38 changes: 38 additions & 0 deletions elvis.config
@@ -0,0 +1,38 @@
[
{
elvis,
[
{config,
[#{dirs => ["src"],
filter => "*.erl",
rules => [{elvis_style, line_length, #{limit => 80,
skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_style, macro_names},
{elvis_style, macro_module_names},
{elvis_style, operator_spaces, #{rules => [{right, ","},
{right, "++"},
{left, "++"}]}},
{elvis_style, nesting_level, #{level => 3}},
{elvis_style, god_modules, #{limit => 30}},
{elvis_style, no_if_expression},
{elvis_style, invalid_dynamic_call, #{ignore => [elvis]}},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{
elvis_style,
module_naming_convention,
#{regex => "^g([a-z][a-z0-9]*_?)*(_SUITE)?$",
ignore => []}
},
{elvis_style, state_record_and_type},
{elvis_style, no_spec_with_records},
{elvis_style, dont_repeat_yourself, #{min_complexity => 10}}
]
}
]
}
]
}
].

0 comments on commit 5e7420f

Please sign in to comment.