Erwan
- Added crude possibility to search for the library (see Diabolic tutor)
This commit is contained in:
@@ -506,6 +506,17 @@ type=Instant
|
||||
mana={W}
|
||||
[/card]
|
||||
[card]
|
||||
text=Search your library for a card and put that card into your hand. Then shuffle your library.
|
||||
target=*|mylibrary
|
||||
auto=moveTo(myHand)
|
||||
id=129525
|
||||
name=Diabolic Tutor
|
||||
rarity=U
|
||||
color=Black
|
||||
type=Sorcery
|
||||
mana={1}
|
||||
[/card]
|
||||
[card]
|
||||
text={B}, {T}, Sacrifice Doomed Necromancer: Return target creature card from your graveyard to play.
|
||||
auto={B},{T},{S}:moveTo(myinplay) target(creature|mygraveyard)
|
||||
id=129880
|
||||
|
||||
@@ -13,7 +13,7 @@ class CardDisplay:public PlayGuiObjectController{
|
||||
TargetChooser * tc;
|
||||
JGuiListener * listener;
|
||||
CardDisplay();
|
||||
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 );
|
||||
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener = NULL, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 );
|
||||
void AddCard(MTGCardInstance * _card);
|
||||
void rotateLeft();
|
||||
void rotateRight();
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "TargetChooser.h"
|
||||
#include "PhaseRing.h"
|
||||
|
||||
#define MAX_GAME_OBSERVERS 500
|
||||
|
||||
|
||||
class MTGGamePhase;
|
||||
class MTGAbility;
|
||||
@@ -34,7 +32,9 @@ class GameObserver{
|
||||
|
||||
|
||||
public:
|
||||
int forceShuffleLibrary[2];
|
||||
int turn;
|
||||
int forceShuffleLibraries();
|
||||
int targetListIsSet(MTGCardInstance * card);
|
||||
PhaseRing * phaseRing;
|
||||
int cancelCurrentAction();
|
||||
|
||||
@@ -31,7 +31,7 @@ class TargetChooser: public TargetsList {
|
||||
|
||||
MTGCardInstance * source; //Optionnal source, used for protection from...
|
||||
int maxtargets; //Set to -1 for "unlimited"
|
||||
|
||||
virtual int targetsZone(MTGGameZone * z){return 0;};
|
||||
int ForceTargetListReady();
|
||||
int targetsReadyCheck();
|
||||
virtual int addTarget(Targetable * target);
|
||||
@@ -57,6 +57,7 @@ class TargetZoneChooser:public TargetChooser{
|
||||
MTGGameZone * zones[6];
|
||||
int nbzones;
|
||||
int init(MTGGameZone ** _zones, int _nbzones);
|
||||
int targetsZone(MTGGameZone * z);
|
||||
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
|
||||
TargetZoneChooser(MTGGameZone ** _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
|
||||
virtual int canTarget(Targetable * _card);
|
||||
|
||||
@@ -57,11 +57,10 @@ void CardDisplay::rotateRight(){
|
||||
bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_CROSS == key)
|
||||
{
|
||||
if (listener != NULL)
|
||||
{
|
||||
listener->ButtonPressed(mId, 0);
|
||||
return true;
|
||||
}
|
||||
if (listener){
|
||||
listener->ButtonPressed(mId, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mCount)
|
||||
|
||||
@@ -148,12 +148,26 @@ void GameObserver::userRequestNextGamePhase(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GameObserver::forceShuffleLibraries(){
|
||||
OutputDebugString("FORCING\n");
|
||||
int result = 0;
|
||||
for (int i=0; i<2; i++){
|
||||
if (forceShuffleLibrary[i]) {
|
||||
forceShuffleLibrary[i] = 0;
|
||||
players[i]->game->library->shuffle();
|
||||
result++;
|
||||
OutputDebugString("YAY\n");
|
||||
}
|
||||
}
|
||||
if (result) mLayers->playLayer()->forceUpdateCards();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GameObserver::startGame(int shuffle, int draw){
|
||||
int i;
|
||||
for (i=0; i<nbPlayers; i++){
|
||||
players[i]->game->initGame(shuffle, draw);
|
||||
forceShuffleLibrary[i] = 0;
|
||||
}
|
||||
|
||||
//Preload images from hand
|
||||
@@ -281,7 +295,20 @@ void GameObserver::ButtonPressed (int controllerId, PlayGuiObject * _object){
|
||||
MTGCardInstance * card = ((CardGui *)_object)->card;
|
||||
cardClick(card, card);
|
||||
}
|
||||
//if (id>= -6 && id <= -3){
|
||||
if (id== -6 || id == -4){ //libraries
|
||||
GuiGameZone * zone = (GuiGameZone *)_object;
|
||||
if (zone->showCards){
|
||||
zone->toggleDisplay();
|
||||
forceShuffleLibraries();
|
||||
} else {
|
||||
int pId = (-id - 4)/2;
|
||||
if (targetChooser && targetChooser->targetsZone(players[pId]->game->library)){
|
||||
zone->toggleDisplay();
|
||||
forceShuffleLibrary[pId] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (id== -5 || id == -3){ //TODO libraries ???
|
||||
GuiGameZone * zone = (GuiGameZone *)_object;
|
||||
zone->toggleDisplay();
|
||||
|
||||
@@ -268,6 +268,7 @@ Player * MTGCardInstance::controller(){
|
||||
if (game->players[i]->game->stack->hasCard(this)) return game->players[i];
|
||||
if (game->players[i]->game->graveyard->hasCard(this)) return game->players[i];
|
||||
if (game->players[i]->game->hand->hasCard(this)) return game->players[i];
|
||||
if (game->players[i]->game->library->hasCard(this)) return game->players[i];
|
||||
}
|
||||
return lastController;
|
||||
}
|
||||
|
||||
@@ -417,5 +417,12 @@ MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * sourc
|
||||
if(zoneName.compare("targetownerremovedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("ownerremovedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("removedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
|
||||
if(zoneName.compare("mylibrary") == 0)return p->game->library;
|
||||
if(zoneName.compare("opponentlibrary") == 0) return p->opponent()->game->library;
|
||||
if(zoneName.compare("targetownerlibrary") == 0) return target->owner->game->library;
|
||||
if(zoneName.compare("targetcontrollerlibrary") == 0) return p2->game->library;
|
||||
if(zoneName.compare("ownerlibrary") == 0) return target->owner->game->library;
|
||||
if(zoneName.compare("library") == 0) return p->game->library;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void GuiGameZone::Render(){
|
||||
}
|
||||
|
||||
void GuiGameZone::ButtonPressed(int controllerId, int controlId){
|
||||
toggleDisplay();
|
||||
GameObserver::GetInstance()->ButtonPressed(GetId(), this);
|
||||
}
|
||||
|
||||
void GuiGameZone::Update(float dt){
|
||||
@@ -139,7 +139,7 @@ void GuiGameZone::Update(float dt){
|
||||
}
|
||||
|
||||
GuiGameZone::GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone): PlayGuiObject(id, desiredHeight, _x, _y, hasFocus), zone(_zone){
|
||||
cd = NEW CardDisplay(id, GameObserver::GetInstance(), _x, _y, this);
|
||||
cd = NEW CardDisplay(id, GameObserver::GetInstance(), _x, _y,this);
|
||||
showCards = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,99 +74,7 @@ int PlayGuiObjectController::getClosestItem(int direction, float tolerance){
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int PlayGuiObjectController::getClosestItem(int direction, float tolerance){
|
||||
if (mCount == 0){
|
||||
return -1;
|
||||
}
|
||||
if (mCount == 1){
|
||||
return mCurr;
|
||||
}
|
||||
|
||||
float MaxTolerance = SCREEN_HEIGHT;
|
||||
PlayGuiObject * current = (PlayGuiObject *)mObjects[mCurr];
|
||||
int found = 0;
|
||||
int closest_match_id = -1;
|
||||
for (int i=0;i<mCount;i++){
|
||||
fprintf(stderr, "distance STEP 3-%i\n", i);
|
||||
if (i != mCurr){ //Don't wanna return the same object as currently selected
|
||||
if (closest_match_id == -1){
|
||||
closest_match_id = i;
|
||||
}
|
||||
if (mObjects[i]!=NULL){
|
||||
float x0, y0, x1, y1,closest;
|
||||
PlayGuiObject * closest_match = (PlayGuiObject *)mObjects[closest_match_id];
|
||||
PlayGuiObject * other = (PlayGuiObject *) mObjects[i];
|
||||
fprintf(stderr, "distance STEP 4-%i\n", i);
|
||||
switch(direction){
|
||||
case DIR_DOWN:
|
||||
x0 = current->x;
|
||||
y0 = current->y;
|
||||
x1 = other->x;
|
||||
y1 = other->y;
|
||||
closest = closest_match->y - y0;
|
||||
break;
|
||||
case DIR_UP:
|
||||
x0 = current->x;
|
||||
y0 = other->y;
|
||||
x1 = other->x;
|
||||
y1 = current->y;
|
||||
closest = y1 - closest_match->y;
|
||||
break;
|
||||
case DIR_LEFT:
|
||||
MaxTolerance = SCREEN_WIDTH;
|
||||
x0 = current->y;
|
||||
y1 = current->x;
|
||||
x1 = other->y;
|
||||
y0 = other->x;
|
||||
closest = y1 - closest_match->x;
|
||||
break;
|
||||
case DIR_RIGHT:
|
||||
MaxTolerance = SCREEN_WIDTH;
|
||||
x0 = current->y;
|
||||
fprintf(stderr, "distance STEP 401\n");
|
||||
|
||||
y0 = current->x;
|
||||
fprintf(stderr, "distance STEP 402\n");
|
||||
x1 = other->y;
|
||||
fprintf(stderr, "distance STEP 403\n");
|
||||
y1 = other->x;
|
||||
fprintf(stderr, "distance STEP 404\n");
|
||||
closest = closest_match->x - y0;
|
||||
fprintf(stderr, "distance STEP 405\n");
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "distance STEP 5\n");
|
||||
float distance = y1-y0;
|
||||
float lateral_distance = fabs(x1-x0);
|
||||
fprintf(stderr, "distance STEP 6 \n");
|
||||
if (lateral_distance < tolerance){
|
||||
fprintf(stderr, "distance STEP 7\n");
|
||||
if (distance > 0 && (!found || (distance < closest && closest > 0 ))){
|
||||
|
||||
found = 1;
|
||||
closest_match_id = i;
|
||||
fprintf(stderr, "distance STEP 8\n");
|
||||
}
|
||||
}
|
||||
}// if (mObjects[i]!=NULL)
|
||||
}
|
||||
}
|
||||
if (!found){
|
||||
fprintf(stderr, "NOT FOUND !\n");
|
||||
if (tolerance < MaxTolerance){
|
||||
fprintf(stderr, "distance STEP 9\n");
|
||||
return getClosestItem(direction, tolerance + 5);
|
||||
}else{
|
||||
fprintf(stderr, "Closest Match ID: %i\n", mCurr);
|
||||
return mCurr;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Closest Match ID: %i\n", closest_match_id);
|
||||
return closest_match_id;
|
||||
|
||||
}
|
||||
*/
|
||||
void PlayGuiObjectController::Update(float dt){
|
||||
last_user_move +=dt;
|
||||
for (int i=0;i<mCount;i++){
|
||||
|
||||
@@ -469,6 +469,7 @@ int CreatureTargetChooser::canTarget(Targetable * target){
|
||||
}
|
||||
|
||||
|
||||
/* TargetzoneChooser targets everything in a given zone */
|
||||
TargetZoneChooser::TargetZoneChooser(MTGCardInstance * card, int _maxtargets){
|
||||
init(NULL,0);
|
||||
source = card;
|
||||
@@ -511,6 +512,14 @@ OutputDebugString ("CHECKING INTERRUPTIBLE\n");
|
||||
}
|
||||
|
||||
|
||||
int TargetZoneChooser::targetsZone(MTGGameZone * z){
|
||||
for (int i = 0; i < nbzones; i++){
|
||||
if (zones[i] == z) return 1;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Player Target */
|
||||
int PlayerTargetChooser::canTarget(Targetable * target){
|
||||
if (target->typeAsTarget() == TARGET_PLAYER){
|
||||
|
||||
Reference in New Issue
Block a user