?? pip_store.c
字號:
/*---------------------------------------------------------------------------*//* 商店選單:食物 零食 大補丸 玩具 書本 *//* *//*---------------------------------------------------------------------------*/#include <time.h>#include "bbs.h"#include "pip.h"#include "site.h"extern struct chicken d;extern time_t start_time;extern time_t lasttime;#ifndef MAPLE//extern char BBS_FULL_NAME[];#endif // END MAPLE//#define getdata(a, b, c , d, e, f, g) getdata(a,b,c,d,e,f,NULL,g)/*---------------------------------------------------------------------------*//* 商店選單:食物 零食 大補丸 玩具 書本 *//* 資料庫 *//*---------------------------------------------------------------------------*//*--------------------------------------------------------------------------*//* 物品參數設定 *//*--------------------------------------------------------------------------*/struct goodsofpip { int num; /*編號 */ char *name; /*名字 */ char *msgbuy; /*功用 */ char *msguse; /*說明 */ int money; /*金錢 */ int change; /*改變量 */ int pic1; int pic2;};typedef struct goodsofpip goodsofpip;const struct goodsofpip pipfoodlist[] = { 0, "物品名", "說明buy", "說明feed", 0, 0, 0, 0, 1, "好吃的食物", "體力恢復50", "每吃一次食物會恢復體力50喔!", 50, 50, 1, 1, 2, "美味的零食", "體力恢復100", "除了恢復體力,小雞也會更快樂", 120, 100, 2, 3, 0, NULL, NULL, NULL, 0, 0, 0, 0};const struct goodsofpip pipmedicinelist[] = { 0, "物品名", "說明buy", "說明feed", 0, 0, 0, 0, 1, "好用大補丸", "體力恢復600", "恢復大量流失體力的良方", 500, 600, 4, 4, 2, "珍貴的靈芝", "法力恢復50", "每吃一次靈芝會恢復法力50喔!", 100, 50, 7, 7, 3, "千年人參王", "法力恢復500", "恢復大量流失法力的良方", 800, 500, 7, 7, 4, "天山雪蓮", "法力體力最大", "這個 好貴......", 10000, 0, 7, 7, 0, NULL, NULL, NULL, 0, 0, 0, 0};const struct goodsofpip pipotherlist[] = { 0, "物品名", "說明buy", "說明feed", 0, 0, 0, 0, 1, "樂高玩具組", "快樂滿意度", "玩具讓小雞更快樂啦...", 50, 0, 5, 5, 2, "百科全書", "知識的來源", "書本讓小雞更聰明更有氣質啦...", 100, 0, 6, 6, 0, NULL, NULL, NULL, 0, 0, 0, 0};/*--------------------------------------------------------------------------*//* 武器參數設定 *//*--------------------------------------------------------------------------*/struct weapon { char *name; /*名字 */ int needmaxhp; /*需要hp */ int needmaxmp; /*需要mp */ int needspeed; /*需要的speed */ int attack; /*攻擊 */ int resist; /*防護 */ int speed; /*速度 */ int cost; /*買價 */ int sell; /*賣價 */ int special; /*特別 */ int map; /*圖檔 */};typedef struct weapon weapon;/*名字,需hp,需mp,需speed,攻擊,防護,速度,買價,賣價,特別,圖檔*/const struct weapon headlist[] = { "不買裝備", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "塑膠帽子", 0, 0, 0, 0, 5, 0, 500, 300, 0, 0, "牛皮小帽", 0, 0, 0, 0, 10, 0, 3500, 1000, 0, 0, " 安全帽", 60, 0, 0, 0, 20, 0, 5000, 3500, 0, 0, "鋼鐵頭盔", 150, 50, 0, 0, 30, 0, 10000, 6000, 0, 0, "魔法發箍", 100, 150, 0, 0, 25, 0, 50000, 10000, 0, 0, "黃金圣盔", 300, 300, 300, 0, 100, 0, 300000, 100000, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/*名字,需hp,需mp,需speed,攻擊,防護,速度,買價,賣價,特別,圖檔*/const struct weapon rhandlist[] = { "不買裝備", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "大木棒", 0, 0, 0, 5, 0, 0, 1000, 700, 0, 0, "金屬扳手", 0, 0, 0, 10, 0, 0, 2500, 1000, 0, 0, "青銅劍", 50, 0, 0, 20, 0, 0, 6000, 4000, 0, 0, "晴雷劍", 80, 0, 0, 30, 0, 0, 10000, 8000, 0, 0, "蟬翼刀", 100, 20, 0, 40, 0, 0, 15000, 10000, 0, 0, "忘情劍", 100, 40, 0, 35, 20, 0, 15000, 10000, 0, 0, "獅頭寶刀", 150, 0, 0, 60, 0, 0, 35000, 20000, 0, 0, "屠龍刀", 200, 0, 0, 100, 0, 0, 50000, 25000, 0, 0, "黃金圣杖", 300, 300, 300, 100, 20, 0, 150000, 100000, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/*名字,需hp,需mp,需speed,攻擊,防護,速度,買價,賣價,特別,圖檔*/const struct weapon lhandlist[] = { "不買裝備", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "大木棒", 0, 0, 0, 5, 0, 0, 1000, 700, 0, 0, "金屬扳手", 0, 0, 0, 10, 0, 0, 1500, 1000, 0, 0, "木盾", 0, 0, 0, 0, 10, 0, 2000, 1500, 0, 0, "不銹鋼盾", 60, 0, 0, 0, 25, 0, 5000, 3000, 0, 0, "白金之盾", 80, 0, 0, 10, 40, 0, 15000, 10000, 0, 0, "魔法盾", 80, 100, 0, 20, 60, 0, 80000, 50000, 0, 0, "黃金圣盾", 300, 300, 300, 30, 100, 0, 150000, 100000, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/*名字,需hp,需mp,需speed,攻擊,防護,速度,買價,賣價,特別,圖檔*/const struct weapon bodylist[] = { "不買裝備", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "塑膠胄甲", 40, 0, 0, 0, 5, 0, 1000, 700, 0, 0, "特級皮甲", 50, 0, 0, 0, 10, 0, 2500, 1000, 0, 0, "鋼鐵盔甲", 80, 0, 0, 0, 25, 0, 5000, 3500, 0, 0, "魔法披風", 80, 40, 0, 0, 20, 20, 15500, 10000, 0, 0, "白金盔甲", 100, 30, 0, 0, 40, 20, 30000, 20000, 0, 0, "黃金圣衣", 300, 300, 300, 30, 100, 0, 150000, 100000, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/*名字,需hp,需mp,需speed,攻擊,防護,速度,買價,賣價,特別,圖檔*/const struct weapon footlist[] = { "不買裝備", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "塑膠拖鞋", 0, 0, 0, 0, 0, 10, 800, 500, 0, 0, "東洋木屐", 0, 0, 0, 15, 0, 10, 1000, 700, 0, 0, "特級雨鞋", 0, 0, 0, 0, 10, 10, 1500, 1000, 0, 0, "NIKE運動鞋", 70, 0, 0, 0, 10, 40, 8000, 5000, 0, 0, "鱷魚皮靴", 80, 20, 0, 10, 25, 20, 12000, 8000, 0, 0, "飛天魔靴", 100, 100, 0, 30, 50, 60, 25000, 10000, 0, 0, "黃金圣靴", 300, 300, 300, 50, 100, 100, 150000, 100000, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/*---------------------------------------------------------------------------*//* 商店選單:食物 零食 大補丸 玩具 書本 *//* 函式庫 *//*---------------------------------------------------------------------------*/int pip_store_food(){ int num[3]; num[0] = 2; num[1] = d.food; num[2] = d.cookie; pip_buy_goods_new(1, pipfoodlist, num); d.food = num[1]; d.cookie = num[2]; return 0;}int pip_store_medicine(){ int num[5]; num[0] = 4; num[1] = d.bighp; num[2] = d.medicine; num[3] = d.ginseng; num[4] = d.snowgrass; pip_buy_goods_new(2, pipmedicinelist, num); d.bighp = num[1]; d.medicine = num[2]; d.ginseng = num[3]; d.snowgrass = num[4]; return 0;}int pip_store_other(){ int num[3]; num[0] = 2; num[1] = d.playtool; num[2] = d.book; pip_buy_goods_new(3, pipotherlist, num); d.playtool = num[1]; d.book = num[2]; return 0;}int pip_store_weapon_head(){ /*頭部武器 */ d.weaponhead = pip_weapon_doing_menu(d.weaponhead, 0, headlist); return 0;}int pip_store_weapon_rhand(){ /*右手武器 */ d.weaponrhand = pip_weapon_doing_menu(d.weaponrhand, 1, rhandlist); return 0;}int pip_store_weapon_lhand(){ /*左手武器 */ d.weaponlhand = pip_weapon_doing_menu(d.weaponlhand, 2, lhandlist); return 0;}int pip_store_weapon_body(){ /*身體武器 */ d.weaponbody = pip_weapon_doing_menu(d.weaponbody, 3, bodylist); return 0;}int pip_store_weapon_foot(){ /*足部武器 */ d.weaponfoot = pip_weapon_doing_menu(d.weaponfoot, 4, footlist); return 0;}int pip_buy_goods_new(mode, p, oldnum)int mode;int oldnum[];struct goodsofpip *p;{ const static char *shopname[4] = { "店名", "便利商店", "星空藥鋪", "夜里書局" }; char inbuf[256]; char genbuf[20]; long smoney; int oldmoney; int i, pipkey, choice; oldmoney = d.money; do { clrchyiuan(6, 18); move(6, 0); sprintf(inbuf, "[1;31m —[41;37m 編號 [0;1;31m—[41;37m 商 品 [0;1;31m——[41;37m 效 能 [0;1;31m——[41;37m 價 格 [0;1;31m—[37;41m 擁有數量 [0;1;31m—[0m "); prints(inbuf); for (i = 1; i <= oldnum[0]; i++) { move(7 + i, 0); sprintf(inbuf, " [1;35m[[37m%2d[35m] [36m%-10s [37m%-14s [1;33m%-10d [1;32m%-9d [0m", p[i].num, p[i].name, p[i].msgbuy, p[i].money, oldnum[i]); prints(inbuf); } clrchyiuan(19, 24); move(b_lines, 0); sprintf(inbuf, "[1;44;37m %8s選單 [46m [B]買入物品 [S]賣出物品 [Q]跳出: [m", shopname[mode]); prints(inbuf); pipkey = igetkey(); switch (pipkey) { case 'B': case 'b': move(b_lines - 1, 1); sprintf(inbuf, "想要買入啥呢? [0]放棄買入 [1~%d]物品商號", oldnum[0]);#ifdef MAPLE getdata(b_lines - 1, 1, inbuf, genbuf, 3, LCECHO, "0");#else getdata(b_lines - 1, 1, inbuf, genbuf, 3, DOECHO, true); if ((genbuf[0] >= 'A') && (genbuf[0] <= 'Z')) genbuf[0] = genbuf[0] | 32;#endif // END MAPLE choice = atoi(genbuf); if (choice >= 1 && choice <= oldnum[0]) { clrchyiuan(6, 18); if (rand() % 2 > 0) show_buy_pic(p[choice].pic1); else show_buy_pic(p[choice].pic2); move(b_lines - 1, 0); clrtoeol(); move(b_lines - 1, 1); smoney = 0; if (mode == 3) smoney = 1; else { sprintf(inbuf, "你要買入物品 [%s] 多少個呢?(上限 %d)", p[choice].name, d.money / p[choice].money);#ifdef MAPLE getdata(b_lines - 1, 1, inbuf, genbuf, 6, 1, 0);#else getdata(b_lines - 1, 1, inbuf, genbuf, 6, DOECHO, true);#endif // END MAPLE smoney = atoi(genbuf);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -