Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.96 KB | None | 0 0
  1. #!/bin/bash
  2. filename="$1"
  3. total=0
  4. rane=0
  5. foul=0
  6. dagon=0
  7. talwin=0
  8. while read -r line
  9. do
  10.     name="$line"
  11.     char=`echo $line |cut -d ' ' -f 1`
  12.     ore=`echo $line |cut -d ' ' -f 2`
  13.     amount=`echo $line |cut -d ' ' -f 3`
  14.  
  15.     if echo $ore |grep -q "Lavish" ; then
  16.       S=$(echo "$amount*1.15"| bc )
  17.       amount=`echo ${S%.*}`
  18.     elif echo $ore |grep -q "Replete" ; then
  19.       S=$(echo "$amount*1.15"| bc )
  20.       amount=`echo ${S%.*}`
  21.  
  22.     fi
  23.     temp=$((total+amount))
  24.     total=$temp
  25.     if echo $char|grep -q "Moon"; then
  26.       rane=$((rane+amount))
  27.     elif echo $char|grep -q "Niminen"; then
  28.      talwin=$((talwin+amount))
  29.     elif echo $char|grep -q "KaTecho"; then
  30.      foul=$((foul+amount))
  31.     elif echo $char|grep -q "FOULPLAY75"; then
  32.      foul=$((foul+amount))
  33.     elif echo $char|grep -q "Dagon"; then
  34.      dagon=$((dagon+amount))
  35.     elif echo $char|grep -q "Dagon"; then
  36.      dagon=$((dagon+amount))
  37.     elif echo $char|grep -q "Rob-Halford"; then
  38.      dagon=$((dagon+amount))
  39.     elif echo $char|grep -q "DefenderoftheFaith"; then
  40.      dagon=$((dagon+amount))
  41.     elif echo $char|grep -q "Britishsteel"; then
  42.      dagon=$((dagon+amount))
  43.     elif echo $char|grep -q "SadWingsOfDestiny"; then
  44.      dagon=$((dagon+amount))
  45.  
  46.     fi
  47.  
  48. done < "$filename"
  49. echo "Rane mined : $rane"
  50. echo "Talwin mined: $talwin"
  51. echo "Foul mined: $foul"
  52. echo "Dagon mined: $dagon"
  53. echo "The total amount is: $total"
  54. tot=$((rane+talwin+dagon+foul))
  55. echo "total if adding all chars this and the above one should be the same: $tot"
  56. rane_per=$( echo "scale=3; $rane/$total*$2"| bc )
  57. echo "Ranes %: $rane_per"
  58. talwin_per=$( echo "scale=3; $talwin/$total*$2"| bc )
  59. echo "Talwins %: $talwin_per"
  60. foul_per=$( echo "scale=3; $foul/$total*$2"| bc )
  61. echo "Fouls %: $foul_per"
  62. dagon_per=$( echo "scale=3; $dagon/$total*$2"| bc )
  63. echo "Dagons %: $dagon_per"
  64. a=$(echo " scale=3; 1-$2"| bc )
  65. share=$(echo "scale=3; $total*$a"| bc )
  66. echo "Corps share in m3 is $share"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement