📄 moneyd.c
字号:
// moneyd.c 钱的功能// by Xiang@XKX (95/12/22)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) return output + chinese_number(amount) + "文铜钱"; return output;}string price_str(int amount){ // returns a chinese string of `amount` of money string output; if (amount < 1) amount = 1; if (amount / 10000) { output = chinese_number(amount / 10000) + "两黄金"; amount %= 10000; } else output = ""; if (amount / 100) { if (output != "") output += "又" + chinese_number(amount / 100) + "两白银"; else output = chinese_number(amount / 100) + "两白银"; amount %= 100; } if (amount) if (output != "") return output + "又" + chinese_number(amount) + "文铜板"; else return chinese_number(amount) + "文铜板"; return output;}void pay_player(object who, int amount){ int v; object ob; seteuid(getuid()); if (amount < 1) amount = 1; if (v = amount / 10000) { ob = new(GOLD_OB); ob->set_amount(amount / 10000); ob->move(who); amount %= 10000; } if (amount / 100) { ob = new(SILVER_OB); ob->set_amount(amount / 100); ob->move(who); amount %= 100; } if (amount) { ob = new(COIN_OB); ob->set_amount(amount); ob->move(who); }}int player_pay(object who, int amount){ object g_ob, s_ob, c_ob; int gc, sc, cc, left; seteuid(getuid()); if (g_ob = present("gold_money", who)) gc = g_ob->query_amount(); else gc = 0; if (s_ob = present("silver_money", who)) sc = s_ob->query_amount(); else sc = 0; if (c_ob = present("coin_money", who)) cc = c_ob->query_amount(); else cc = 0; if (cc + sc * 100 + gc * 10000 < amount) if (present("thousand-cash", who)) return 2; else return 0; else { left = cc + sc * 100 + gc * 10000 - amount; gc = left / 10000; left = left % 10000; sc = left / 100; cc = left % 100; if (g_ob) g_ob->set_amount(gc); else sc += (gc * 100); if (s_ob) s_ob->set_amount(sc); else if (sc) { s_ob = new(SILVER_OB); s_ob->set_amount(sc); s_ob->move(who); } if (c_ob) c_ob->set_amount(cc); else if (cc) { c_ob = new(COIN_OB); c_ob->set_amount(cc); c_ob->move(who); } return 1; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -