lib/warcards.rb in warcards-0.0.2 vs lib/warcards.rb in warcards-0.0.3
- old
+ new
@@ -1,23 +1,63 @@
-require 'bundler/setup'
-Bundler.require(:default)
require_relative 'warcards/gameplay'
require 'querinator'
module Cardgame
class Game
def initialize
- @questions = Querinator::Game.new.get_questions
- @deck = Deck.new
- @player = Player.new
- @ai = Ai.new
- @gameplay = Gameplay.new(:deck => @deck, :player => @player, :ai => @ai)
+ @deck = Deck.new
+ @player = Player.new
+ @ai = Ai.new
+ @gameplay = Gameplay.new(:deck => @deck, :player => @player, :ai => @ai)
@gameplay.shuffle
@gameplay.deal
+ @output = Struct.new(:winner, :player_feedback, :ai_feedback, :posed)
+
end
+ ##def output
+ ## @output
+ ##end
+ ##
+ ##def rearm?
+ ## @gameplay.rearm?
+ ##end
+ ##
+ ##def show_cards
+ ## @gameplay.show_cards
+ ##end
+ ##
+ ##def war?
+ ## @gameplay.contest
+ ##end
+ ##
+ ##def contest
+ ## @gameplay.contest
+ ##end
+ ##
+ ##def discard(result)
+ ## @gameplay.discard(result)
+ ##end
+ ##
+ ##def game_over?
+ ## @gameplay.game_over?
+ ##end
+ #
+ #def player
+ # @player
+ #end
+ #
+ #def ai
+ # @ai
+ #end
+
def run
+ filename = get_filename
+ until File.file? filename
+ get_filename
+ end
+ @questions = Querinator::Game.new.get_questions(filename)
loop do
@gameplay.game_over?
@gameplay.rearm?
@gameplay.show_cards
@gameplay.war?
@@ -28,10 +68,18 @@
continue?
@gameplay.discard(result)
end
end
+ def get_filename
+ puts "What question file?\nfilename: "
+ filename = gets.chomp
+ file = File.expand_path(filename)
+ p file
+ file
+ end
+
def continue?
puts "go again?\n"
next_round = gets
if next_round.downcase.chomp.include? "n"
puts "You ended the game"
@@ -85,12 +133,12 @@
puts question.pose
answer = gets
question.is_correct?(answer.chomp)
end
- #TODO make this configurable
- def test_ai
- @ai.difficulty_check?(rand, 0.9)
+ def test_ai(difficulty)
+ difficulty ||= 0.4
+ @ai.difficulty_check?(rand, difficulty)
end
end
end