Exemplo n.º 1
0
FloorItem::FloorItem(const BeingId id,
                     const int itemId,
                     const int x, const int y,
                     const ItemTypeT itemType,
                     const int amount,
                     const int refine,
                     const ItemColor color,
                     const Identified identified,
                     const Damaged damaged,
                     const int *const cards) :
    ActorSprite(id),
    mCards(),
    mItemId(itemId),
    mX(x),
    mY(y),
    mDropTime(cur_time),
    mAmount(amount),
    mRefine(refine),
    mHeightPosDiff(0),
    mItemType(itemType),
    mPickupCount(0),
    mCursor(Cursor::CURSOR_PICKUP),
    mColor(color),
    mIdentified(identified),
    mDamaged(damaged),
    mShowMsg(true),
    mHighlight(config.getBoolValue("floorItemsHighlight"))
{
    setCards(cards, maxCards);
}
Exemplo n.º 2
0
void GameManager::initCards()
{
	QStringList cardsNames, c1, c2;
	int i = 0, j = 0, k = 0;
	
	c1 << "king" << "queen" << "jack";
	c2 << "club" << "diamond" << "heart" << "spade"; 
	
	for(i = 0; i < c2.count(); i++)
	{
		for(j = 0; j < c1.count(); j++)
			cardsNames << c1.at(j) + "_" + c2.at(i);
		for(k = 1; k <= 10; k++)
			cardsNames << QString().setNum(k) + "_" + c2.at(i);
	}
	cardsNames += cardsNames;
	
	shuflleCards(cardsNames);
	setCards(cardsNames);
	
	connect(&(basePiles.at(0)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(1)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(2)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(3)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(4)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(5)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(6)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(7)) , SIGNAL(fullPileBase()), SLOT(endGame()));
}
Exemplo n.º 3
0
HoleCards::HoleCards(const QString & first,
                     const QString & second)
{
   setCards(first, second);
}
Exemplo n.º 4
0
bool GameScene::init(){
	if (!Layer::init())
	{
		return false;
	}


	//游戏数据初始化
	card_num = 0;
	debt_num = 0;



	//先添加桌面背景,在最下面
	auto * table = Sprite::create("table.png");
	this->addChild(table);
	auto screenSize = Director::getInstance()->getWinSize();//获取屏幕尺寸  
	table->setPosition(screenSize.width/2,screenSize.height/2-30);
	table->setScale(1.1);//设置缩放级别
	
	//add buttons
	//按钮上的文字后期用ps来制作

	auto giveUpMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_giveUp, this));
	giveUpMenuItem->setPosition(Point(60, 40));

	auto genZhuMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_xiaZhu, this));
	genZhuMenuItem->setPosition(Point(190, 40));

	auto yiLvMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_jiaZhu, this));
	yiLvMenuItem->setPosition(Point(320, 40));

	auto starMenu = Menu::create(giveUpMenuItem, genZhuMenuItem,yiLvMenuItem,NULL);
	starMenu->setPosition(Point::ZERO);
	
	this->addChild(starMenu, 1);

	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label01 = Label::createWithSystemFont("giveUp", "Arial", 17);
	button_label01->setPosition(Point(60, 40));
	this->addChild(button_label01,2);
	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label02 = Label::createWithSystemFont("xiaZhu", "Arial", 17);
	button_label02->setPosition(Point(190, 40));
	this->addChild(button_label02,2);
	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label03 = Label::createWithSystemFont("jiaZhu", "Arial", 17);
	button_label03->setPosition(Point(320, 40));
	this->addChild(button_label03,2);




	// your codes here 
	
	/*

	char str[] = "poker_pic/13.png";
	auto test_card = Sprite::create(str);
	this->addChild(test_card);
	test_card->setPosition(screenSize.width / 2, screenSize.height -400);
	test_card->setScale(0.6);

	auto my_testCard = Card::create("roomgirl.png");  // auto == Card
	my_testCard->setPosition(screenSize.width / 2, screenSize.height - 200);
	my_testCard->setScale(0.6);
	my_testCard->setCardID(23);
	this->addChild(my_testCard);
	CCLOG("my_testCard->ID = %d .", my_testCard->getCardID());//会得到log:my_testCard->ID = 23 .

	*/

	//test_end

	//显示玩家头像,玩家筹码等信息,荷官的片,
	auto roomgirl = Sprite::create("roomgirl.png");
	this->addChild(roomgirl);
	roomgirl->setPosition(screenSize.width/2, screenSize.height-70);
	roomgirl->setScale(1);

	
	player_num = 2;//设置为2名玩家

	//添加游戏玩家(other players)
	auto player01 = addNewPlayer("player01", 50000);

	int my_total = 50000;
	char *my_name = "player_me";
	//添加自己的游戏数据========
	player_me = Player::create("default_player.png");//创建纹理,并且显示在屏幕的正下方
	player_me->setPhoto("default_player.png");
	player_me->setPosition(screenSize.width/2,170);
	player_me->setDebt(0); //set to 0
	player_me->setTotal(my_total);
	player_me->setOnTable(true);
	this->addChild(player_me);
	player01->setPlayerName(my_name);
	player01->setTotal(my_total);

	//show player name
	auto player_me_name = Label::createWithSystemFont(my_name, "Arial", 17);
	player_me_name->setPosition(screenSize.width/2, 215);
	this->addChild(player_me_name);

	//show player total money
	char tmp[9];
	sprintf(tmp, "%d",my_total);
	auto player_me_total = Label::createWithSystemFont(tmp, "Arial", 17);
	player_me_total->setPosition(screenSize.width/2,120);
	this->addChild(player_me_total);


	

	//下底注(后期可以用ps来制作一张图来支持中文)
	//show tips
	auto tips = Sprite::create("show_tips.png");
	tips->setScale(0.3);
	tips->setPosition(screenSize.width / 2, screenSize.height / 2);
	tips->setOpacity(200);
	this->addChild(tips, 0, 100);// set tag 100
	auto tips_label = Label::createWithSystemFont("XiaDiZhu", "SimSun", 30);
	tips_label->setPosition(screenSize.width / 2, screenSize.height / 2);
	tips_label->setColor(ccc3(0, 0, 0));//color black
	this->addChild(tips_label, 0, 101);// set tag 101
	this->scheduleOnce(schedule_selector(GameScene::showTips), 1);//调用回调函数来删掉刚刚创建的tips 
	
	
	player01->addDebt(DIZHU);
	player_me->addDebt(DIZHU);

	debt_num = DIZHU * 2;
	//CCLOG为调试信息
	CCLOG("player01.debt = %d ,total = %d", player01->getDebt(), player01->getTotal());
	CCLOG("player_me.debt = %d ,total = %d", player_me->getDebt(), player_me->getTotal());


	//发底牌(2张底牌)保证不相同
	srand((unsigned)time(NULL)); //初始化随机数种子

	int t1 = getOneNumber();//两名玩家共4张底牌
	int t2 = getOneNumber();
	int t3 = getOneNumber();
	int t4 = getOneNumber();
	CCLOG("DIPAI  == %d %d %d %d",t1,t2,t3,t4);
	player01->setCards(t1,t2);
	player_me->setCards(t3,t4);

	//CCLOG("PLAYER01 c1 = %d, c2 = %d ,PLAYER_ME  c3 = %d, c4 =%d ", player01->getCard01(), player01->getCard02(), player_me->getCard01(), player_me->getCard02());


	//显示玩家得到的底牌(可以添加动画效果)
	char poker_file_name[20]="poker_pic/";
	char temp[9];
	sprintf(temp, "%d", player_me->getCard01());
	strcat(poker_file_name,temp);
	strcat(poker_file_name, ".png");
	//CCLOG("poker_file_name 1 = %s", poker_file_name);
	auto dipai01 = Card::create(poker_file_name);
	dipai01->setRotation(-13);//旋转角度 
	dipai01->setScale(0.5);
	dipai01->setPosition(320, 165);
	this->addChild(dipai01);

	//重新创建一个变量
	char poker_file_name2[20] = "poker_pic/";
	sprintf(temp, "%d", player_me->getCard02());
	strcat(poker_file_name2, temp);
	strcat(poker_file_name2, ".png");
	//CCLOG("poker_file_name 2 = %s", poker_file_name2);
	auto dipai02 = Card::create(poker_file_name2);
	dipai02->setRotation(9);//旋转角度 
	dipai02->setScale(0.5);
	dipai02->setPosition(340, 165);
	this->addChild(dipai02);

	//添加背面的牌:
	auto hand_card_R = Sprite::create("hand_card_back.png");
	hand_card_R->setScale(0.6);
	hand_card_R->setPosition(22, 470);
	this->addChild(hand_card_R);

	//刚发过底牌,设置一个标签,来定义玩到了什么进度
	game_round = 1;//刚发过底牌,设置为1
	
	//若不弃牌,则下注,下注之后可选加注


	//庄家下注,玩家跟注?加注?

	//发第一张公共牌

	//发第二张公共牌

	//...

	//...直到发最后一张公共牌,是否加注?判断游戏输赢
	
	//以上内容写在了按钮中,通过读取变量值来知道是第几个回合

	return true;//init函数执行成功,返回真
}