Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo "Joining game..."
- portdata=`nc localhost 3336`
- port=`echo $portdata | awk '{print $2;}'`
- player=`echo $portdata | awk '{print $1;}'`
- p=$((player*9))
- echo $USER| nc localhost $port
- echo "You are Player $player"
- echo "Waiting for your turn..."
- stats(){
- clear
- (printf "Side Player Money Cities Colonies Favor Reserve Engaged XP\n"; \
- for ((x=0;x<${#g[@]};x+=9)); do echo; \
- echo "$((x/9)) ${g[@]:$x:8}"; done ) | column -t
- echo
- }
- while ((1))
- do
- gamedata=`nc -l $port`
- count=0
- for a in $gamedata
- do
- g[count]=$a
- ((count++))
- done
- g[$((p+1))]=$((g[p+1]+g[p+2]*50*g[p+4]/100+g[p+3]*10*g[p+4]/100))
- ((g[p+5]+=g[p+6]))&&((g[p+6]=0))
- clear
- (printf "${g[p+8]}"; echo "**Press q to start your turn**")| sed s'/_/ /g' | less
- g[$((p+8))]="EVENTS:\n"
- choice=0
- while ((choice!=8))
- do
- clear
- echo "Player $player Your Gold: ${g[$((p+1))]} ****------MAIN MENU------****"
- echo "---------------------------------------------------------------"
- echo " 1.)Stats"
- echo " 2.)Build Colony **COSTS 50g**"
- echo " 3.)Build City **COSTS 100g & REQUIRES COLONY**"
- echo " 4.)Cloak and Dagger"
- echo " 5.)Troop Menu"
- echo " 6.)Battle Menu"
- echo " 7.)Message"
- echo " 8.)End Turn"
- echo
- echo
- read choice
- case "$choice" in
- "1")
- stats
- read blank
- ;;
- "2")
- if ((g[$((p+1))]>=50))
- then
- ((g[$((p+1))]-=50))
- ((g[$((p+3))]++))
- else
- echo "Not enough gold for colony"
- sleep 1
- fi
- ;;
- "3")
- if ((g[$((p+1))]>=100&&g[$((p+3))]>0))
- then
- ((g[$((p+1))]-=100))
- ((g[$((p+2))]++))
- ((g[$((p+3))]--))
- else
- echo "Not enough gold or you don't have colonies to make city"
- sleep 1
- fi
- ;;
- "4")
- stats
- echo "Enter target (Side):"
- read target
- clear
- echo "Target: $target Your Gold: ${g[$((p+1))]} ****------CLOAK AND DAGGER------****"
- echo "---------------------------------------------------------------"
- echo "1.) KILL POLITICAL ENEMIES - 50g +3 FAVOR"
- echo "2.) ASSASSINATE FAMILY MEMBER- 50g -3 FAVOR"
- echo "3.) SET PALACE ON FIRE -100g -6 FAVOR"
- echo "4.) CANCEL"
- echo
- echo "Assassin: What is your bidding, my master?"
- read option
- case "$option" in
- "1")
- if((g[$((p+1))]>=50))
- then
- echo "Assassin: Excellent choice."
- sleep 1
- ((g[$((p+1))]-=50))
- ((g[$((target*9+4))]+=3))
- g[$((target*9+8))]="${g[$((target*9+8))]}Your_enemies_have_been_killed_by_$USER._+3_FAVOR\n"
- else
- echo "Assassin: Sadly I do not operate in the absence of funds."
- sleep 1
- fi
- ;;
- "2")
- if((g[$((p+1))]>=50))
- then
- echo "Assassin: Excellent choice."
- sleep 1
- ((g[$((p+1))]-=50))
- ((g[$((target*9+4))]-=3))
- g[$((target*9+8))]="${g[$((target*9+8))]}Your_family_has_been_murdered_by_$USER._-3_FAVOR\n"
- else
- echo "Assassin: Sadly I do not operate in the absence of funds."
- sleep 1
- fi
- ;;
- "3")
- if((g[$((p+1))]>=100))
- then
- echo "Assassin: Excellent choice."
- sleep 1
- ((g[$((p+1))]-=100))
- ((g[$((target*9+4))]-=6))
- g[$((target*9+8))]="${g[$((target*9+8))]}Your_palace_has_been_murdered_by_$USER._-6_FAVOR\n"
- else
- echo "Assassin: Sadly I do not operate in the absence of funds."
- sleep 1
- fi
- ;;
- esac
- ;;
- "5")
- clear
- echo "Player $player Your Gold: ${g[$((p+1))]} Reserve: ${g[$((p+5))]} ****------TROOP MENU------****"
- echo "---------------------------------------------------------------"
- echo " 1.)Build Troops **COSTS 1g**"
- echo " 2.)Train Troops **Makes them Engaged**"
- echo " 3.)Cancel"
- echo
- echo
- read tchoice
- case "$tchoice" in
- "1")
- echo "How many?"
- read tnumber
- if((tnumber<=g[$((p+1))]))
- then
- ((g[$((p+1))]-=tnumber))
- ((g[$((p+5))]+=tnumber))
- ((g[$((p+7))]-=tnumber*25/(g[$((p+6))]+g[$((p+5))])))
- (((g[$((p+7))]<0)&&(g[$((p+7))]=0)))
- echo "$tnumber Troops Drafted"
- echo "XP: ${g[$((p+7))]}"
- sleep 1
- else
- echo "You don't have enough gold."
- fi
- ;;
- "2")
- echo "How many?"
- read tnumber
- if((tnumber<=g[$((p+5))]))
- then
- ((g[$((p+5))]-=tnumber))
- ((g[$((p+6))]+=tnumber))
- ((g[$((p+7))]+=tnumber*50/(g[$((p+6))]+g[$((p+5))])))
- (((g[$((p+7))]>100)&&(g[$((p+7))]=100)))
- echo "$tnumber Troops Trained"
- echo "XP: ${g[$((p+7))]}"
- sleep 1
- else
- echo "You don't have enough troops."
- fi
- ;;
- esac
- ;;
- "6")
- stats
- echo "Enter target (Side):"
- read target
- t=$((target*9))
- clear
- echo "Player $player Reserve: ${g[$((p+5))]} ****------BATTLE MENU------****"
- echo "---------------------------------------------------------------"
- echo " 1.)CONQUER **(Very hard if there are still cities)**"
- ((g[$((t+2))]>0)) && echo " 2.)CAPTURE CITY **(There is a +100 troop bonus to defenders)**"
- ((g[$((t+3))]>0)) && echo " 3.)RAID COLONY **(50% Enemy Defensive Strength)**"
- echo
- echo
- read bchoice
- case "$bchoice" in
- "2")
- echo "How many troops?"
- read bnum
- if((bnum<=g[$((p+5))]))
- then
- aforce=$((bnum*g[p+4]/100+bnum*g[p+7]/100))
- dnum=$((aforce*100/(g[t+4]+g[t+7])))
- dif=$((g[t+5]-dnum))
- ((dif<0))&&((dnum+=dif))
- dforce=$(((dnum+100)*g[t+4]/100+(dnum+100)*g[t+7]/100))
- battle=$((aforce-dforce))
- dk=$dnum
- ak=$bnum
- if((battle>0))
- then
- ak=$((bnum-(battle*100/(g[t+4]+g[t+7]))))
- echo "You captured ${g[t]}'s city."
- echo "+5 Favor"
- ((g[t+2]--))
- ((g[p+2]++))
- ((g[p+4]+=5))
- ((g[p+7]+=10))
- (((g[p+7]+10)<=100))&&((g[p+7]=100))
- echo "XP=${g[$((p+7))]}"
- elif((battle<0))
- then
- dk=$((dnum+(battle*100/(g[t+4]+g[t+7]))))
- echo "You Lost"
- fi
- ((g[p+5]-=bnum))
- ((g[p+6]+=(bnum-ak)))
- ((g[t+5]-=dnum))
- ((g[t+6]+=(dnum-dk)))
- g[$((t+8))]="${g[$((t+8))]}Your_city_has_been_attacked_by_$USER!\nAttackers:_${bnum}_KIA:_${ak}\nDefenders:_${dnum}_KIA:_${dk}\n"
- sleep 1
- else
- echo "You don't have that many troops"
- fi
- ;;
- "3")
- echo "How many troops?"
- read bnum
- if((bnum<=g[$((p+5))]))
- then
- aforce=$((bnum*g[p+4]/100+bnum*g[p+7]/100))
- dnum=$((aforce*100/(g[t+4]+g[t+7])+50))
- dif=$((g[t+5]/2-dnum))
- ((dif<0))&&((dnum+=dif))
- dforce=$((dnum*g[t+4]/100+dnum*g[t+7]/100))
- battle=$((aforce-dforce))
- dk=$dnum
- ak=$bnum
- if((battle>0))
- then
- ak=$((bnum-(battle*100/(g[t+4]+g[t+7]))))
- echo "You destroyed ${g[t]}'s colony."
- echo "+2 Favor"
- ((g[t+3]--))
- ((g[p+4]+=2))
- ((g[p+7]+=5))
- (((g[p+7]+5)<=100))&&((g[p+7]=100))
- echo "XP=${g[$((p+7))]}"
- elif((battle<0))
- then
- dk=$((dnum+(battle*100/(g[t+4]+g[t+7]))))
- echo "You Lost"
- fi
- ((g[p+5]-=bnum))
- ((g[p+6]+=(bnum-ak)))
- ((g[t+5]-=dnum))
- ((g[t+6]+=(dnum-dk)))
- g[$((t+8))]="${g[$((t+8))]}Your_colony_has_been_attacked_by_$USER!\nAttackers:_${bnum}_KIA:_${ak}\nDefenders:_${dnum}_KIA:_${dk}\n"
- sleep 1
- else
- echo "You don't have that many troops"
- fi
- ;;
- esac
- esac
- done
- echo ${g[@]} | nc localhost $port
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement