#!/usr/bin/ruby require "itemappearance.rb" class ElRingAppearance < ElItemAppearance def initialize(appearance) super(:ring, appearance) rings = [ # identity price [:adornment, 100], [:hunger, 100], [:protection, 100], [:protection_from_shape_changers, 100], [:stealth, 100], [:sustain_ability, 100], [:warning, 100], [:aggravate_monster, 150], [:cold_resistance, 150], [:gain_constitution, 150], [:gain_strength, 150], [:increase_accuracy, 150], [:increase_damage, 150], [:invisibility, 150], [:poison_resistance, 150], [:see_invisible, 150], [:shock_resistance, 150], [:fire_resistance, 200], [:free_action, 200], [:levitation, 200], [:regeneration, 200], [:searching, 200], [:slow_digestion, 200], [:teleportation, 200], [:conflict, 300], [:polymorph, 300], [:polymorph_control, 300], [:teleport_control, 300] ] @possible_identities = {} rings.each {|ring| @possible_identities[ring[0]] = 0 } @price_of = {} rings.each {|ring| @price_of[ring[0]] = ring[1] } end def sink_msg(msg) # TODO: in some cases, we can tell if the ring was positively or # negatively enchanted based on the response. We should utilize this # information in case the sink rolls the small chance to regurgitate # the ring. if msg =~ /You thought your ring got lost in the sink, but there it is!/ identify_as(:searching) elsif msg =~ /The ring is regurgitated!/ identify_as(:slow_digestion) elsif msg =~ /The sink quivers upwards for a moment\./ identify_as(:levitation) elsif msg =~ /You smell rotten / identify_as(:poison_resistance) elsif msg =~ /Several flies buzz angrily around the sink\./ identify_as(:aggravate_monster) elsif msg =~ /Static electricity surrounds the sink\./ identify_as(:shock_resistance) elsif msg =~ /You hear loud noises coming from the drain\./ identify_as(:conflict) elsif msg =~ /The water flow seems fixed\./ identify_as(:sustain_ability) elsif msg =~ /The water flow seems (stronger|weaker) now\./ identify_as(:gain_strength) elsif msg =~ /The water flow seems (lesser|greater) now\./ identify_as(:gain_constitution) elsif msg =~ /The water flow (misses|hits) the drain\./ identify_as(:increase_accuracy) elsif msg =~ /The water's force seems (smaller|greater) now\./ identify_as(:increase_damage) elsif msg =~ /Suddenly, .* vanishes from the sink!/ identify_as(:hunger) elsif msg =~ /The faucets flash brightly for a moment\./ identify_as(:adornment) elsif msg =~ /The sink looks as good as new\./ identify_as(:regeneration) elsif msg =~ /You don't see anything happen to the sink\./ identify_as(:invisibility) elsif msg =~ /You see the ring slide right down the drain!/ identify_as(:free_action) elsif msg =~ /You see some air in the sink\./ identify_as(:see_invisible) elsif msg =~ /The sink seems to blend into the floor for a moment\./ identify_as(:stealth) elsif msg =~ /The hot water faucet flashes brightly for a moment\./ identify_as(:fire_resistance) elsif msg =~ /The cold water faucet flashes brightly for a moment\./ identify_as(:cold_resistance) elsif msg =~ /The sink looks nothing like a fountain\./ identify_as(:protection_from_shape_changers) elsif msg =~ /The sink glows (black|silver) for a moment\./ identify_as(:protection) elsif msg =~ /The sink glows white for a moment\./ identify_as(:warning) elsif msg =~ /The sink momentarily vanishes\./ identify_as(:teleportation) elsif msg =~ /The sink looks like it is being beamed aboard somewhere\./ identify_as(:teleport_control) elsif msg =~ /The sink momentarily looks like a fountain\./ identify_as(:polymorph) elsif msg =~ /The sink momentarily looks like a regularly erupting geyser\./ identify_as(:polymorph_control) end end end for i in ["wooden", "granite", "opal", "clay", "coral", "black onyx", "moonstone", "tiger eye", "jade", "bronze", "agate", "topaz", "sapphire", "ruby", "diamond", "pearl", "iron", "brass", "copper", "twisted", "steel", "silver", "gold", "ivory", "emerald", "wire", "engagement", "shiny"] ElRingAppearance.new(i) end if __FILE__ == $0 require "../utils/assert.rb" wooden = ElRingAppearance.find("wooden") wooden.sink_msg("Suddenly, HanClinto vanishes from the sink!") assert_eq("Sink testing", wooden.identity, :hunger) print "unit test succeeded\n" end