diff --git a/ai.c b/ai.c index 56a98c44b1ae437bfd44f35538872b64c3775ed4..263b83a3589cb415be07f4b86a6db0a4787fa47d 100644 --- a/ai.c +++ b/ai.c @@ -1,13 +1,71 @@ #include "zgs.h" +int select_card(int id,char* type) +{ + int i=0; + while(player[id].card[i].type!= type&&iplayer[id].card_number){ + return -1;} + + return i; +} + + +void pick_crad(int id) +{ + player[id].card[(player[id].card_number+1)] = get_a_card(); + player[id].card_number++; + player[id].card[(player[id].card_number+1)] = get_a_card(); + player[id].card_number++; + +} + +int health_check(int id) +{ + int i; + if(player[id].health<4) + i=0; + else + i=1; + return i; + +} + +void cure(int id) +{ + int i; + do + { + if (health_check(id)==0) + i=select_card(id,"p"); + if(i==-1){ + return NULL;} + //ues peach to player[id] + use(id,i); + }while(player[id].health<4); + +} + void mp_play(int id){ show_pig(id,1); + pick_crad(id); + cure(id); + + } void zp_play(int id){ show_pig(id,1); + pick_crad(id); + cure(id); + cure(1); } void fp_play(int id){ show_pig(id,1); + pick_crad(id); + cure(id); }