예제 #1
0
char *ParsePortSpec( char * *spec )
{
    char    *parm;
    int     port;

    parm = (spec == NULL) ? "" : *spec;

    switch( *parm ) {
    case '1':
        ++parm;
        /* fall through */
    case '.':
    case '\0':
        port = 0;
        IntVector = 4;
        IOBase = 0x3f8;
        break;
    case '2':
        ++parm;
        port = 1;
        IntVector = 3;
        IOBase = 0x2f8;
        break;
    default:
        return( TRP_ERR_invalid_serial_port_number );
    }
    if( *parm != '\0' && *parm != '.' ) return( TRP_ERR_invalid_serial_port_number );
    if( port >= Equipment().num_rs232s ) return( TRP_ERR_serial_port_does_not_exist );
    if( spec != NULL ) *spec = parm;
    return( NULL );
}
예제 #2
0
std::shared_ptr<Armor> ObjectFactory::createArmor(TemplateArmor &armorTemplate, RarityType &rarityType){
	int defence =
		(int)(engine::defenceMax *
		armorTemplate.defenceFromMax *
		rarityType.improvementMultiplier *
		engine::random.variationMultiplier(engine::statisticVariation));

	double durability =
		engine::durabilityMax *
		armorTemplate.durabilityFromMax *
		engine::random.variationMultiplier(engine::statisticVariation);

	std::shared_ptr<Armor> armor = std::shared_ptr<Armor>(new Armor(
		Equipment(Item(engine::raritySystem.getArmorMod(rarityType),
		GameObject(
		armorTemplate.name,
		armorTemplate.type,
		armorTemplate.glyph),
		armorTemplate.weightKg,
		armorTemplate.limbsRequiredToHold),
		durability),
		armorTemplate.limbsRequiredToEquip,
		defence
		));

	//rarity color
	armor->glyph.fgColor = armor->glyph.fgColor * rarityType.color;
	
	return armor;
}
예제 #3
0
std::shared_ptr<Weapon> ObjectFactory::createWeapon(TemplateWeapon &weaponTemplate, RarityType &rarityType){
	int damage =
		(int)(engine::damageMax *
		weaponTemplate.damageFromMax *
		rarityType.improvementMultiplier *
		engine::random.variationMultiplier(engine::statisticVariation));

	double durability = 
		engine::durabilityMax * 
		weaponTemplate.durabilityFromMax *
		engine::random.variationMultiplier(engine::statisticVariation);

	std::shared_ptr<Weapon> weapon = std::shared_ptr<Weapon>(new Weapon(
		Equipment(Item(engine::raritySystem.getWeaponMod(rarityType),
		GameObject(
		weaponTemplate.name,
		weaponTemplate.type,
		weaponTemplate.glyph),
		weaponTemplate.weightKg,
		weaponTemplate.limbsRequiredToHold),
		durability),
		damage,
		*engine::objectLibrary.creatureSkills[weaponTemplate.skillId]
		));

	//rarity color
	weapon->glyph.fgColor = weapon->glyph.fgColor * rarityType.color;

	return weapon;
}
예제 #4
0
Room::Room()
{
	Boss endBoss = Boss(10);
	RandomGenerator rg = RandomGenerator();
	size = RoomSize[rg.getRandom(0, 2)];
	content = RoomContent[rg.getRandom(0, 3)];
	description = RoomDescription[rg.getRandom(0, 3)];
	appearance = RoomAppearance[rg.getRandom(0, 3)];
	lighting = RoomLighting[rg.getRandom(0,3)];
	connected[RoomDirection::NORTH] =  nullptr;
	connected[RoomDirection::EAST] = nullptr;
	connected[RoomDirection::SOUTH] = nullptr;
	connected[RoomDirection::WEST] = nullptr;
	visited = false;
	visiting = false;
	exit = false;
	equipment.push_back(Equipment());
}
예제 #5
0
Room::Room(int room)
{
	number = room;
	Boss endBoss = Boss(10);
	RandomGenerator rg;
	size = RoomSize[rg.getRandom(0, 2)];
	content = RoomContent[rg.getRandom(0, 3)];
	description = RoomDescription[rg.getRandom(0, 3)];
	appearance = RoomAppearance[rg.getRandom(0, 3)];
	lighting = RoomLighting[rg.getRandom(0, 3)];
	color = RoomColor[rg.getRandom(0, 3)];
	connected[RoomDirection::NORTH] = nullptr;
	connected[RoomDirection::EAST] = nullptr;
	connected[RoomDirection::SOUTH] = nullptr;
	connected[RoomDirection::WEST] = nullptr;
	visited = false;
	visiting = false;
	exit = false;
	equipment.push_back(Equipment());
	if (rg.getRandom(0, 100) < 20)
		traps.push_back(Trap());
}
예제 #6
0
void Interface::MainGame()
{
	string input = "";
	vector<string> parsedInput;
	bool quitGame = false;
	Look();
	cout << "Type 'help' (no ' marks) for a short explanation of basic commands." << endl;
	cout << "Make sure to use the 'growth' command before gaining experience!" << endl;
	while(!quitGame)
	{
		Prompt();
		getline(cin, input);
		for (int i = 0; i < input.size(); i++)
			input[i] = tolower(input[i]);
		parsedInput = ParseInput(input);
		command cmd = CommandControl::GetInstance()->GetCommand(parsedInput.front());
		string target = parsedInput.back();
		if (cmd == LOOK)
			Look();
		if (cmd == GO_NORTH)
			North();
		if (cmd == GO_SOUTH)
			South();
		if (cmd == GO_EAST)
			East();
		if (cmd == GO_WEST)
			West();
		if (cmd == GO_DOWN)
			Down();
		if (cmd == GO_UP)
			Up();
		if (cmd == KILL)
			Kill(parsedInput.back());
		if (cmd == SCORE)
			Score();
		if (cmd == ABILITIES)
			Abilities();
		if (cmd == HELP)
			Help();
		if (cmd == GROWTH)
			Growth();
		if (cmd == QUIT)
			Quit();
		if (cmd == INVENTORY)
			Inventory();
		if (cmd == EQUIPMENT)
			Equipment();
		if (cmd == WEAR)
			Wear(parsedInput.back());
		if (cmd == REMOVE)
			Remove(parsedInput.back());
		if (cmd == EXAMINE)
		{	
			command targetCmd = CommandControl::GetInstance()->GetCommand(parsedInput.back());
			if (targetCmd == INVENTORY)
				ExaInv();
			else if (targetCmd == EQUIPMENT)
				ExaEquip();
			else if (targetCmd == LOOK)
				ExaLook();
			else
				cout << "That is not a valid target to examine." << endl;
		}
		if (cmd == GET)
			Get(parsedInput.back());
		if (cmd == DROP)
			Drop(parsedInput.back());
		if (cmd == USE)
			Use(parsedInput.back());
		if (cmd == SAVE)
			SavePlayer();
	}
}