// store.c by konn
#include <ansi.h>
#include <mudlib.h>
inherit ROOM;

int do_list();
int do_trade(string);
int do_buy(string);

void create() {
        set("short","马匹集散中心");
        set("long",@LONG

    这里是全国最大的马匹销售中心。你可以在这里找到你所需要的马
    来与您并肩作战, 从这里向里望去, 只见一整排的马厩, 而里面所
    饲养的马都是当今最珍贵的马种。你可以使用list查看这里有卖哪
    些好马。

LONG);
        set("exits",([ /* sizeof() == 1 */
            "west" : "/open/port/room/r2-2",
      ]));

        set("objects",([ /* sizeof() == 1 */
//          "open/gblade/npc/boss1.c" : 1,
      ]));
       
        set("light_up", 1);
        setup();
}

void init() {
        add_action("do_list","list");
        add_action("do_trade","trade");
        add_action("do_buyy","buy");
}

int do_list() {
        return notify_fail("

            小店所贩卖的马匹如下:

        赤兔马 (Red horse)         exp : 800000         :  15 金 50 银
        乌黑驹 (Black horse)       exp : 500000         :  14 金 60 银
        龙骧马 (Dragon horse)      exp : 400000         :  12 金 20 银
        骐驎驹 (Jeelin horse)      exp : 250000         :  11 金 40 银
        騊駼驹 (Tau horse)         exp : 100000         :  10 金  0 银
        驒騱\驹 (Twosee horse)      exp : 50000          :   9 金 20 银
        骅骝驹 (Whaliu horse)      exp :  10000         :   7 金 40 银
        驌驦驹 (Sueswan horse)     exp :      0         :   5 金 80 银

            您只需下 trade <名称> 即可采购, 谢谢您的光临!\n\n");
}

int do_buyy(string str) {
        return notify_fail("您只需下 trade <名称> 即可采购。\n");
}

int do_trade(string str) {
        int gold,silver,exp,i,money;
        object me,horse;
        me = this_player();

        if(me->query_temp("have_horse"))
           return notify_fail(HIY"董老板说道: 一个人只能买一匹马ㄛ...\n"NOR);

        switch(str) {
           case "red horse"     :
              horse = new("/open/gblade/npc/horse/horse1");
              break;
           case "black horse"   :
              horse = new("/open/gblade/npc/horse/horse2");
              break;
           case "dragon horse"  :
              horse = new("/open/gblade/npc/horse/horse3");
              break;
           case "jeelin horse"  :
              horse = new("/open/gblade/npc/horse/horse4");
              break;
           case "tau horse"     :
              horse = new("/open/gblade/npc/horse/horse5");
              break;
           case "twosee horse"  :
              horse = new("/open/gblade/npc/horse/horse6");
              break;
           case "whaliu horse"  :
              horse = new("/open/gblade/npc/horse/horse7");
              break;
           case "sueswan horse" :
              horse = new("/open/gblade/npc/horse/horse8");
              break;
           default : return notify_fail(HIY"董老板说道:"+
                                        " 抱歉! 本店并不售这种东西!\n"NOR);
        }

        exp = (int)horse->query("exp");
        gold = (int)horse->query("gold");
        silver = (int)horse->query("silver");
        money = gold*10000 + silver*100;

        if(me->query("combat_exp") < exp)
           return notify_fail(HIY"董老板说道:"+
                              " 你恐怕无法驾驭此马, 请另选一匹吧!\n"NOR);

        if(!me->pay_money(money))
	   return notify_fail(HIY"董老板说道:"+
               " 你的钱不够, 我的马匹无法卖给你!\n"NOR);

	me = this_player();
        horse->move(environment(me));
        horse->set_leader(me);
        horse->set_temp("my_boss",(string)me->query("id"));
        me->set_temp("have_horse", 1);
        message_vision(HIC"$N买下了一匹马!\n"NOR,me);
        return notify_fail(HIY"董老板说道: 谢谢您的惠顾! 请下次再来!\n"NOR);
}
