void SectorBuilder::parse_body(const FileReader& reader) { { // check version int version = 1; if (!reader.get("version", version)) std::cerr << "Warning no version specified in levelformat.\n"; if (version > 3) std::cerr << "Warning: format version is newer than game.\n"; } //reader.get("name", name); //reader.get("music", music); //reader.get("init-script", init_script); Color ambient_light; if (reader.get("ambient-color", ambient_light)) { m_sector.set_ambient_light(ambient_light); } parse_objects(reader); parse_navgraph(reader); }
int json_test() { hbc::file_input_stream input_stream("json/watch_on_mobile.json"); hbc::json_pull parser(&input_stream); parse_objects(parser, 0); return 0; }
int cmd_psidrain (string str) { object ob; int ma, psi, damage, def; if (!spell()) { return 0; } if(!str) { ob = (object)this_player()->query_current_attacker(); if(!ob) { notify_fail("Psidrain what?\n"); return 0; } } else ob = present(str, environment(this_player())); if(!ob) ob = parse_objects(environment(this_player()), str); if(!ob || !living(ob)) { notify_fail("Look again.\n"); return 0; } if (this_player()->query_busy()) return notify_fail("You are busy.\n"); if(environment(this_player())->query_property("no magic") || environment(this_player())->query_property("no attack")) { notify_fail("A magic force prevents your use of magic here.\n"); return 0; } if(!psi=(int)this_player()->query_skill("psionics")) { notify_fail("You do not have the mental abilities for this.\n"); return 0; } if(!ma=(int)this_player()->query_skill("magic attack")) { notify_fail("Your magic is not yet strong enough for this spell.\n"); return 0; } if((int)this_player()->query_mp() < 30) { notify_fail("Too low on magic power.\n"); return 0; } if(this_player()->query_ghost()) { notify_fail("Your voice is hollow.\n"); return 0; } if(this_player()->query_casting()) return 1; if(!this_player()->kill_ob(ob)) { write(ob->query_cap_name()+" can't be attacked by you yet."); return 1; } if(environment(this_player())->query_property("no attack")) { notify_fail("A magic force prevents you from casting your spell.\n"); return 0; } write("%^BOLD%^You drain the mental strength of "+(string)ob->query_cap_name()+" and " "feel stronger.%^RESET%^"); tell_room(environment(this_player()), this_player()->query_cap_name()+ " suddenly looks stronger.", ({ob, this_player()}));
int cmd_aim(string str) { string what, whom; object ob; if (!abil()) { write("What?\n"); return 1; } if(!str) { notify_fail("Aim for what?\n"); return 0; } if(this_player()->query_disable()) return 1; this_player()->set_disable(); if((int)this_player()->query_sp() < 1) { notify_fail("You are too tired.\n"); return 0; } if(sscanf(str, "for %s on %s", what, whom) != 2) { what = str; ob = (object)this_player()->query_current_attacker(); if(!ob) { notify_fail("Aim for what on whom?\n"); return 0; } } else { ob = present(lower_case(whom), environment(this_player())); if(!ob) ob = parse_objects(environment(this_player()), lower_case(whom)); if(!ob) { notify_fail("No "+capitalize(whom)+" here.\n"); return 0; } } if(!living(ob)) { notify_fail("That is not a living thing!\n"); return 0; } if(!ob->query_is_limb(lower_case(what))) { notify_fail(ob->query_cap_name()+" has no "+what+".\n"); return 0; } write("You aim for "+ob->query_cap_name()+"'s "+what+"."); say(this_player()->query_cap_name()+" concentrates on "+ob->query_cap_name()+"."); if(random(101) < (int)this_player()->query_skill("attack")) ob->set_target_limb(lower_case(what)); this_player()->add_sp(-random(2)-1); return 1; }
int cmd_discern(string str) { string x, limbs; object tp, ob; tp = this_player(); if (!abil()) { notify_fail("What?\n"); return 0; } if((string)tp->query_class() != "fighter") return 0; if(!str) return notify_fail("Discern what?\n"); if(tp->query_sp() < 5) { notify_fail("You fail.\n"); return 0; } ob = present(str, tp); if(!ob) ob = parse_objects(tp, str); if(!ob) { notify_fail("No "+str+" here!\n"); return 0; } x = (string)ob->query_type(); if(!x) { notify_fail("That is neither armour or a weapon!\n"); return 0; } if(!ob->query_wc()) { if(!limbs=ob->query_limbs()) return notify_fail("That is neither armour or a weapon!\n"); tp->add_sp(-10); message("info", sprintf("%s is of type %s.", capitalize(str), x), tp); message("info", sprintf("%s covers your : ", capitalize(str)), tp); message("info", sprintf("%s", format_page(limbs, 5)), tp); return 1; } message("info", sprintf("%s is of type %s.", capitalize(str), x), tp); tp->add_sp(-5); return 1; }
TEST_F(RaconPolishingTest, ConsensusWithQualities) { SetUp(racon_test_data_path + "sample_reads.fastq.gz", racon_test_data_path + "sample_overlaps.paf.gz", racon_test_data_path + "sample_layout.fasta.gz", racon::PolisherType::kC, 500, 10, 0.3, 5, -4, -8); initialize(); std::vector<std::unique_ptr<racon::Sequence>> polished_sequences; polish(polished_sequences, true); EXPECT_EQ(polished_sequences.size(), 1); polished_sequences[0]->create_reverse_complement(); auto parser = bioparser::createParser<bioparser::FastaParser, racon::Sequence>( racon_test_data_path + "sample_reference.fasta.gz"); parser->parse_objects(polished_sequences, -1); EXPECT_EQ(polished_sequences.size(), 2); EXPECT_EQ(calculateEditDistance(polished_sequences[0]->reverse_complement(), polished_sequences[1]->data()), 1312); }
int parse_data_files(int option) { int ret; cf = (config_t *) gtmalloc(sizeof(config_t)); config_init(cf); if (!config_read_file(cf, MAIN_DATA_FILE)) { fprintf(stderr, "%s:%d - %s\n", config_error_file(cf), config_error_line(cf), config_error_text(cf)); config_destroy(cf); return(1); } objid = 1; printf("Reading %s\n", MAIN_DATA_FILE); if(option == ONLY_CONFIG) { ret = parse_configfile(); config_destroy(cf); return ret; } /* TODO: This return value stuff makes rather little sense!! */ ret = parse_configfile(); ret = parse_objects(); ret = parse_monsters(); config_destroy(cf); ret = parse_roomdef_files(); return ret; }
int cmd_give(string str) { object ob, to; string what, who, type; int i, amount; int dummy; // object *inv; if (!stringp(str)) return help(); dummy = total_light(this_player()); if(dummy < -6) { write("It is too dark.\n"); return 1; } if (sscanf(str,"%s to %s", what, who) != 2) { return help(); } if(who == "me" || who == "myself") { who = this_player()->query_name(); } to = present(who, environment(this_player())); if (!to) { notify_fail("Give "+what+" to who?\n"); return 0; } ob = present(what, this_player()); if (ob) if (ob->give(what)) return 1; if (!ob) { ob = parse_objects(this_player(), what); } if(!ob) { if(sscanf(what, "%d %s coin", amount, type) !=2) { return notify_fail("You must have an object to give it away!\n"); } // wiz fixed this, you were able to give 0 coins to people if (amount<1) { return notify_fail("Please enter a valid amount.\n"); } if(amount > (int)this_player()->query_money(type)) { return notify_fail("You don't have that much!\n"); } if(query_ip_number(this_player()) == query_ip_number(to) && this_player()->query_name() != to->query_name() ) { CHAT_D->do_raw_chat("system", "Multi <system> Exchange of money between "+this_player()->query_name()+" and "+to->query_name()); seteuid("Log"); log_file("multiplay", "Exchange of money ("+amount+" "+type+") between "+this_player()->query_name()+" and "+to->query_name()+" from "+query_ip_number(this_player())+". (give)\n"); seteuid(getuid()); } this_player()->add_money(type, -amount); to->add_money(type, amount); if (to->is_monster()) { to->remove_property("gave_money"); to->set_property("gave_money", 1); } write("You give " + amount + " " + type + " coins to " + to->query_cap_name() + ".\n"); message("no_wrap",this_player()->query_cap_name()+ " gives some money to " + to->query_cap_name() + ".\n", environment(this_player()),({ this_player(), to })); tell_object(to, this_player()->query_cap_name() + " gives you " + amount + " " + type + " coins.\n"); return 1; }