scripts/csv_parser.rb
# after gathering up rows 
# create games using cold family feud format
#
# using round number + fast money (4 questions)
# create as many games as possible until we run out
after gathering up rows
create games using cold family feud format

using round number + fast money (4 questions)
create as many games as possible until we run out
after gathering up rows create games using cold family feud format using round number + fast money ( 4 questions ) create as many games as possible until we run out
def createFamilyJson
    if @random
      @@round_arr = @@round_arr.shuffle
    end
    q = 0
    fm = 0
    counter = 0
    fm_rounds = 0
    if @fastmoney
      fm_rounds = 4
    end
    if @fastmoney
      game = {
        rounds: [],
        final_round: [],
        final_round_timers: [20, 25]
      }
    else
      game = {
        rounds: [],
      }
    end
    dp @@round_arr.length()
    @@round_arr.push(nil)
    game_num = ( @@round_arr.length() / (@rounds + fm_rounds) )
    game_num.to_i
    for r in @@round_arr
      if counter == game_num
        unless r.nil?
          p "could not use in a full game with #{@rounds} rounds + #{fm_rounds} fast money rounds => #{r[0]}"
        end
        next
      end
      if q < @rounds
        dp "q => #{q} r => #{r[0]}"
        i = 0
        round_hash = {
          answers: [],
          multiply: q >= (@rounds / 2).to_int && @multiplier ? 2 : 1
        }
        until i > r.length()
          if i == 0
            round_hash["question"] = r[i]
            i += 1
            next
          end
          if i % 2 == 0
            round_hash[:answers].push({
              "ans": r[i-1], "pnt": r[i], "trig": false 
            })
          end
          i += 1
        end
        game[:rounds].push(round_hash)
        q += 1
      else if q == @rounds and @fastmoney and fm  < fm_rounds
        dp "fm => #{fm} r => #{r[0]}"
        i = 0
        round_hash = {
          answers: [],
          selection: 0,
          points: 0,
          input: "",
          revealed: false
        }
        until i > r.length()
          if i == 0
            round_hash["question"] = r[0]
            i += 1
            next
          end
          if i % 2 == 0
            round_hash[:answers].push([r[i-1], r[i]])
          end
          i += 1
        end
        game[:final_round].push(round_hash)
        fm += 1
      else
        unless r.nil?
          dp "reusing #{r[0]} in the next loop"
        end
        q = 0
        fm = 0
        @@file_arr.push(game)
        counter += 1
        dp "#{@@file_arr.length()}"
        if @fastmoney
          game = {
            rounds: [],
            final_round: [],
            final_round_timers: [20, 25]
          }
        else
          game = {
            rounds: [],
          }
        end
        redo
      end
    end
  end
  dp "Number of games => #{@@file_arr.length()}"
end
def createFamilyJson if @random @@round_arr = @@round_arr . shuffle end q = 0 fm = 0 counter = 0 fm_rounds = 0 if @fastmoney fm_rounds = 4 end if @fastmoney game = { rounds : [ ] , final_round : [ ] , final_round_timers : [ 20 , 25 ] } else game = { rounds : [ ] , } end dp @@round_arr . length ( ) @@round_arr . push ( nil ) game_num = ( @@round_arr . length ( ) / ( @rounds + fm_rounds ) ) game_num . to_i for r in @@round_arr if counter == game_num unless r . nil? p "could not use in a full game with #{@rounds} rounds + #{fm_rounds} fast money rounds => #{r[0]}" end next end if q < @rounds dp "q => #{q} r => #{r[0]}" i = 0 round_hash = { answers : [ ] , multiply : q >= ( @rounds / 2 ) . to_int && @multiplier ? 2 : 1 } until i > r . length ( ) if i == 0 round_hash [ "question" ] = r [ i ] i += 1 next end if i % 2 == 0 round_hash [ :answers ] . push ( { "ans" : r [ i - 1 ] , "pnt" : r [ i ] , "trig" : false } ) end i += 1 end game [ :rounds ] . push ( round_hash ) q += 1 else if q == @rounds and @fastmoney and fm < fm_rounds dp "fm => #{fm} r => #{r[0]}" i = 0 round_hash = { answers : [ ] , selection : 0 , points : 0 , input : "" , revealed : false } until i > r . length ( ) if i == 0 round_hash [ "question" ] = r [ 0 ] i += 1 next end if i % 2 == 0 round_hash [ :answers ] . push ( [ r [ i - 1 ] , r [ i ] ] ) end i += 1 end game [ :final_round ] . push ( round_hash ) fm += 1 else unless r . nil? dp "reusing #{r[0]} in the next loop" end q = 0 fm = 0 @@file_arr . push ( game ) counter += 1 dp "#{@@file_arr.length()}" if @fastmoney game = { rounds : [ ] , final_round : [ ] , final_round_timers : [ 20 , 25 ] } else game = { rounds : [ ] , } end redo end end end dp "Number of games => #{@@file_arr.length()}" end
after gathering up rows
create games using cold family feud format
after gathering up rows create games using cold family feud format
# push an empty value for value that is even to rounds + fast money # add in a round # add in a fast money round # push game to files # clear game 