fork download
  1. -module(the_duke).
  2. -behaviour(gen_sovereign).
  3. -export([rule/0]).
  4.  
  5. start(Pars) ->
  6. io:format("The duke is dead. Long live the duke ~p!~n",[Pars]),
  7. gen_sovereign:start_link({local, ?MODULE}, ?MODULE, [Pars], []).
  8.  
  9. stop() ->
  10. io:format("I'm a powerful duke, you can't stope my rule!~n"),
  11. gen_sovereign:cast(?MODULE, revolt).
  12.  
  13. coronation([Pars]) ->
  14. io:format("I am the ruler of duchy ~p!~n",[Pars]),
  15. process_flag(trap_exit, true),
  16. {ok, coronated}.
  17.  
  18. handle_call_to_arms(Message, From, State) when is_ally(From) ->
  19. {accept, raise_grand_army(), State};
  20.  
  21. handle_call_to_arms(Message, king, State) ->
  22. {decline, start_revolt(), State}.
  23.  
  24. handle_info({vassal_doesnt_pay_taxes, Vassal}, State) ->
  25. {send_to_prison, Vassal, State}.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.erl:3: function rule/0 undefined
prog.erl:18: illegal guard expression
prog.erl:19: function raise_grand_army/0 undefined
prog.erl:22: function start_revolt/0 undefined
prog.erl:2: Warning: behaviour gen_sovereign undefined
prog.erl:5: Warning: function start/1 is unused
prog.erl:9: Warning: function stop/0 is unused
prog.erl:13: Warning: function coronation/1 is unused
prog.erl:18: Warning: function handle_call_to_arms/3 is unused
prog.erl:18: Warning: variable 'Message' is unused
prog.erl:21: Warning: variable 'Message' is unused
prog.erl:24: Warning: function handle_info/2 is unused
stdout
Standard output is empty