项目作者: suddi

项目描述 :
Portal game in elixir, based on https://howistart.org/posts/elixir/1
高级语言: Elixir
项目地址: git://github.com/suddi/portal.git
创建时间: 2017-01-16T10:22:14Z
项目社区:https://github.com/suddi/portal

开源协议:MIT License

下载


Portal

Portal game in Elixir following the guide in How I Start..

Usage

To open an Elixir process to communicate through:

  1. iex --sname room1 --cookie secret -S mix

A second process:

  1. iex --sname room2 --cookie secret -S mix

In room1:

  1. iex(room1@zenith)1> Portal.shoot(:blue)
  2. {:ok, #PID<0.118.0>}

In room2:

  1. iex(room2@zenith)1> Portal.Door.get({:blue, :"room1@zenith"})
  2. []
  3. iex(room2@zenith)2> Portal.shoot(:orange)
  4. {:ok, #PID<0.124.0>}
  5. iex(room2@zenith)3> orange = {:orange, :"room2@zenith"}
  6. {:orange, :room2@zenith}
  7. iex(room2@zenith)4> blue = {:blue, :"room1@zenith"}
  8. {:blue, :room1@zenith}
  9. iex(room2@zenith)5> portal = Portal.transfer(orange, blue, [1, 2, 3, 4])
  10. #Portal<
  11. {:orange, :room2@zenith} <=> {:blue, :room1@zenith}
  12. [1, 2, 3, 4] <=> []
  13. >
  14. iex(room2@zenith)6> Portal.push_right(portal)
  15. #Portal<
  16. {:orange, :room2@zenith} <=> {:blue, :room1@zenith}
  17. [1, 2, 3] <=> [4]
  18. >

In room1:

  1. iex(room1@zenith)2> orange = {:orange, :"room2@zenith"}
  2. {:orange, :room2@zenith}
  3. iex(room1@zenith)3> blue = {:blue, :"room1@zenith"}
  4. {:blue, :room1@zenith}
  5. iex(room1@zenith)4> Portal.Door.get(orange)
  6. [3, 2, 1]
  7. iex(room1@zenith)5> Portal.Door.get(blue)
  8. [4]