![]() |
![]() |
#1 |
初级会员
![]() ![]() ![]() ![]() ![]() ![]() 注册: 05年03月12日
来自: 青岛
帖子: 35
声望力: 0
声望:
10
![]() 现金:54两梁山币
资产:141两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
【转帖】qn银行制作(下)
/std/room/bank.c //Cracked by Roath // bank.c inherit ROOM; string money_str(int amount); int pay_player(object who, int amount); int large_deposit(int base_value, int amount); void init() { add_action("do_convert", "convert"); add_action("do_deposit", "deposit"); add_action("do_check", "account"); add_action("do_withdraw", "withdraw"); add_action("do_credit", "credit"); // add_action("do_quit", "quit"); } int do_convert(string arg) { string from, to; int amount, bv1, bv2; object from_ob, to_ob; if( !arg || sscanf(arg, "%d %s to %s", amount, from, to)!=3 ) return notify_fail("指令格式:convert <数量> <货币种类> to <货币种类>\n"); if( this_player()->is_busy() ) return notify_fail("你现在正忙着呢...。\n"); from_ob = present(from + "_money", this_player()); to_ob = present(to + "_money", this_player()); if( !to_ob && file_size("/obj/money/" + to + ".c") < 0 ) return notify_fail("你想兑换哪一种钱?\n"); if( !from_ob ) return notify_fail("你身上没有这种货币。\n"); if( amount < 1 ) return notify_fail("兑换货币一次至少要兑换一个。\n"); if( (int)from_ob->query_amount() < amount ) return notify_fail("你身上没有那么多" + from_ob->query("name") + "。\n"); bv1 = from_ob->query("base_value"); if( !bv1 ) return notify_fail("这种东西不值钱。\n"); bv2 = to_ob ? to_ob->query("base_value") : call_other("/obj/money/" + to, "query", "base_value" ); if( bv1 < bv2 ) amount -= amount % (bv2 / bv1); if( amount==0 ) return notify_fail("这些" + from_ob->query("name") + "的价值太低了,换不起。\n"); this_player()->start_busy(1); if( !to_ob ) { to_ob = new("/obj/money/" + to); if(!(to_ob->move(this_player()))) return 0; to_ob->set_amount(amount * bv1 / bv2); } else to_ob->add_amount(amount * bv1 / bv2); message_vision( sprintf("$N从身上取出%s%s%s,换成%s%s%s。\n", chinese_number(amount), from_ob->query("base_unit"), from_ob->query("name"), chinese_number(amount * bv1 / bv2), to_ob->query("base_unit"), to_ob->query("name")), this_player() ); if( (int)from_ob->query_amount() == amount ) destruct(from_ob); else from_ob->add_amount(-amount); this_player()->save(); return 1; } int do_deposit(string arg) { string what; int amount; object what_ob, me; me = this_player(); if(!arg || sscanf(arg, "%d %s", amount, what) !=2) { return notify_fail("命令格式:deposit <数量> <货币单位>\n"); } if( this_player()->is_busy() ) return notify_fail("你现在正忙着呢...。\n"); what_ob = present(what + "_money", me); if (!what_ob) { return notify_fail("你身上没有带这种钱。\n"); } if (amount < 1) { return notify_fail("你想存多少" + what_ob->query("name") + "?\n"); } if ((int)what_ob->query_amount() < amount) { return notify_fail("你带的" + what_ob->query("name") + "不够。\n"); } me->start_busy(1); message_vision(sprintf("$N拿出%s%s%s,存进了钱庄。\n", chinese_number(amount), what_ob->query("base_unit"), what_ob->query("name")), me); if(to_float(me->query("balance"))+to_float(what_ob->query("base_value")) * to_float(amount)>=2000000000.0) large_deposit(what_ob->query("base_value"),amount); else me->add("balance", what_ob->query("base_value") * amount); if ((int)what_ob->query_amount() == amount) destruct(what_ob); else what_ob->add_amount(-amount); me->save(); return 1; } int do_check() { object me=this_player(); int balance = (int)me->query("balance"); int bcredit = (int)me->query("bcredit"); if(!balance || balance < 0) me->set("balance", 0); else write("您在敝银庄共存有" + money_str(balance) + "\n"); if(!bcredit || bcredit < 0){ me->set("bcredit", 0); if(me->query("balance")==0) return notify_fail("您在敝银庄没有存钱。\n"); } else write("您在敝银庄共存有" +chinese_number(bcredit) + "个信用点。\n"); return 1; } int do_withdraw(string arg) { int amount, v, rv; string what; object me; me = this_player(); if (!arg || sscanf(arg, "%d %s", amount, what) != 2) { return notify_fail("命令格式:withdraw <数量> <货币单位>\n"); } if( this_player()->is_busy() ) return notify_fail("你现在正忙着呢...。\n"); if (amount < 1) { return notify_fail("你想取出多少钱?\n"); } if (file_size("/obj/money/" + what + ".c") < 0) { return notify_fail("你想取出什么钱?\n"); } what = "/obj/money/" + what; if ((v = amount * what->query("base_value")) > me->query("balance")) { return notify_fail("你存的钱不够取。\n"); } if( v < what->query("base_value") ) { return notify_fail("Don't try, or I will purge you!\n"); } me->start_busy(1); /* if( me->query("balance") > me->query("combat_exp")*100) rv = v*8/10; else */ //cuz there is upper limit now, disabled //discount...weiqi,971226. rv = v; // player may not be able to carry the money. // so what get out maybe less than he expected. // mon 6/13/98 v=v-pay_player(me, rv); me->add("balance", -v); me->save(); message_vision(sprintf("$N从银号里取出%s。\n", money_str(v)), me); return 1; } string money_str(int amount) { // returns a chinese string of `amount` of money string output; if (amount / 10000) { output = chinese_number(amount / 10000) + "两黄金"; amount %= 10000; } else output = ""; if (amount / 100) { output = output + chinese_number(amount / 100) + "两白银"; amount %= 100; } if (amount || sizeof(output)<2) return output + chinese_number(amount) + "文铜板"; return output; } // return value is the amount which doesnot paid. // mon 6/13/98 int pay_player(object who, int amount) { int v; object ob; seteuid(getuid()); if (amount < 1) amount = 0; if (v = amount / 10000) { ob = new("/obj/money/gold"); ob->set_amount(amount / 10000); if(!(ob->move(who))) return amount; amount %= 10000; } if (amount / 100) { ob = new("/obj/money/silver"); ob->set_amount(amount / 100); if(!(ob->move(who))) return amount; amount %= 100; } if (amount) { ob = new("/obj/money/coin"); ob->set_amount(amount); if(!(ob->move(who))) return amount; } return 0; } int do_quit() { this_player()->move("/cmds/std/quitroom"); return 1; } int do_credit(string arg) { int balance,bcredit; object me = this_player(),ob; if(!arg) return notify_fail("命令格式:credit credit|balance|withdraw\n"); if( this_player()->is_busy() ) return notify_fail("你现在正忙着呢...。\n"); balance=me->query("balance"); bcredit=me->query("bcredit"); if(!balance || balance<0 ) balance=0; if(!bcredit || bcredit<0 ) bcredit=0; if(arg=="credit") { if(balance<1000000000) return notify_fail("您存在钱庄的银子还不足以换取信用点。\n"); balance-=1000000000; bcredit+=1; message_vision("$N用自己的存款换取了一个信用点。\n", me); } else if(arg=="balance") { if(balance>500000000) return notify_fail("您的存款过多,请取出一些后再来兑换信用点。\n"); if(bcredit<1) return notify_fail("您还没有信用点可以兑换。\n"); balance+=1000000000; bcredit-=1; message_vision("$N将自己的一个信用点兑换成存款。\n", me); } else if(arg=="withdraw") { if(bcredit<1) return notify_fail("您还没有信用点,不能领取信用证!\n"); bcredit-=1; ob=new("/obj/money/credit"); ob->set_amount(1); if(!ob->move(me)) return notify_fail("对不起,银号出了点小问题,暂时不能付给您信用证。\n"); message_vision("$N从银号里取出一张信用证。\n", me); } else return notify_fail("命令格式:credit credit|balance|withdraw\n"); me->set("balance",balance); me->set("bcredit",bcredit); me->start_busy(1); me->save(); return 1; } int large_deposit(int base_value, int amount) { float total; int bcredit, balance; int ah,al,vh,vl; object me=this_player(); balance=me->query("balance"); bcredit=me->query("bcredit"); total=to_float(me->query("balance"))+to_float(base_value) * to_float(amount); bcredit+=to_int(total/1000000000.0); vh=base_value/10000;vl=base_value%10000; ah=amount/10000;al=amount%10000; balance=balance%1000000000+(al*vl+(ah*vl+vh*al)%100000*10000+(ah*vh)%10*100000000)%1000000000; me->set("balance",balance%1000000000); me->set("bcredit",bcredit); return 1; } 此帖于 2005-03-13 05:57 被 dayu 编辑. |
![]() ![]() |
![]() |
![]() |
#2 |
初级会员
![]() ![]() ![]() ![]() ![]() 注册: 05年06月03日
帖子: 43
声望力: 0
声望:
10
![]() 现金:-7两梁山币
资产:-4两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
![]() |
#3 |
初级会员
![]() ![]() 注册: 07年06月22日
来自: 中国
帖子: 15
声望力: 0
声望:
10
![]() 现金:8两梁山币
资产:8两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
KKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
![]() ![]() |
![]() |
![]() |
#4 |
中级会员
![]() ![]() ![]() ![]() ![]() ![]() ![]() 注册: 06年10月15日
帖子: 176
声望力: 20
声望:
10
![]() 现金:1两梁山币
资产:28两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
明出处:水泊梁山 http://www.aolai.org (http://www.skymud
|
![]() |
![]() |
![]() |
#5 |
中级会员
![]() ![]() ![]() ![]() ![]() ![]() 注册: 05年05月06日
来自: 客栈
帖子: 79
声望力: 20
声望:
30
![]() 现金:0两梁山币
资产:121两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
qn银行我喜欢,可是有了后乐趣少很多
|
![]() ![]() |
![]() |
![]() |
#6 |
初级会员
![]() ![]() ![]() 注册: 08年02月09日
帖子: 25
声望力: 0
声望:
10
![]() 现金:25两梁山币
资产:25两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
qian neng bank?
|
![]() |
![]() |
![]() |
#7 |
中级会员
![]() ![]() ![]() ![]() ![]() ![]() ![]() 注册: 06年06月21日
帖子: 178
声望力: 20
声望:
10
![]() 现金:423两梁山币
资产:423两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
学习。。。。。。。。。。。。。。。。。。。
|
![]() |
![]() |
![]() |
#8 |
中级会员
![]() ![]() ![]() ![]() 注册: 08年11月28日
帖子: 68
声望力: 17
声望:
17
![]() 现金:2两梁山币
资产:2两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
回复: 【转帖】qn银行制作(下)
总站里面应该没有这个功能吧!!
|
![]() |
![]() |