Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create test cases and fix typing error #582

Open
wants to merge 167 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
50d685e
adding testOracle package
kbbn2001 Mar 28, 2017
399e2be
create test case AutoIncrementer class
kbbn2001 Mar 28, 2017
5b486db
Make TestBpmOperationResult.java for test BpmOperationResult.java
gxicxigouxa Mar 28, 2017
d77b753
adding test cast to Utilites
kbbn2001 Mar 29, 2017
a14823c
Rename TestBpmOperationResult.java to BpmOperationResultTest.java.
gxicxigouxa Mar 30, 2017
680808b
adding test case testConfigNew
kbbn2001 Mar 30, 2017
51ffa24
adding test cast to ConfigNew.java class
kbbn2001 Apr 1, 2017
78d2045
Updating LoginDataTest.java.
gxicxigouxa Apr 2, 2017
17bac54
Add missing ':' into toString method
gxicxigouxa Apr 2, 2017
9668d76
Make PlayerAccountTest.java for test PlayerAccount.java
gxicxigouxa Apr 2, 2017
1d2757a
Make PokemonModelTest.java for test PokemonModel.java
gxicxigouxa Apr 2, 2017
68df3a4
Fix access modifiers. Make PokemonBagTest.java for test PokemonBag.java.
gxicxigouxa Apr 2, 2017
e11d8c5
Merge pull request #1 from gxicxigouxa/develop
kbbn2001 Apr 3, 2017
3d375a0
pokegoutil.data.managers test
colrong Apr 3, 2017
98cccc0
@testOracle PokeHandlerTest,PokemonCalculationUtilsTest,
lhh8048 Apr 3, 2017
21971c3
Merge pull request #2 from colrong/develop
kbbn2001 Apr 3, 2017
6efde87
Complete comment for LoginDataTest.java.
gxicxigouxa Apr 3, 2017
a92a686
Merge pull request #3 from gxicxigouxa/develop
kbbn2001 Apr 3, 2017
e6ec54b
separate s201224434 into AutoIncrementerTest, ConfigNewTest,
kbbn2001 Apr 3, 2017
7af4428
test cases for
sonyuseon Apr 3, 2017
2bfa55f
Merge pull request #4 from sonyuseon/develop
kbbn2001 Apr 3, 2017
5dbd865
@testOracle PokeHandlerTest,PokemonCalculationUtilsTest,
lhh8048 Apr 3, 2017
85add3d
@testOracle PokeHandlerTest,PokemonCalculationUtilsTest,
lhh8048 Apr 3, 2017
81711a2
adding test case made by LHH.
lhh8048 Apr 3, 2017
b47980b
Merge branch 'develop' into develop
kbbn2001 Apr 3, 2017
ac5f577
Merge pull request #5 from lhh8048/develop
kbbn2001 Apr 3, 2017
408b0b8
delete empty test file
kbbn2001 Apr 4, 2017
adc67c8
refactoring ConfigNew class setBool, setString, setInt, setDouble,
kbbn2001 May 3, 2017
5263f20
Rename : 'keys' to 'allConfigKeys' in ConfigNew class cleanUpAndFill
kbbn2001 May 4, 2017
3dfc65a
Consolidate Conditional Expression / PokemonBagManager's initialize /
colrong May 4, 2017
83a5433
Consolidate Conditional Expression / PokemonManager's initialize /
colrong May 4, 2017
db3bf03
Consolidate Conditional Expression / InventoryManager's initialize /
colrong May 4, 2017
44d6741
Refactoring (Introduce Explaining Variable) : ConfigNew Class
kbbn2001 May 4, 2017
8e03574
Extract Method / AccountManager's deleteLoginData /
colrong May 4, 2017
0e4517d
Remove ternary operator / AccountManager's getPlayerProfile /
colrong May 4, 2017
f664935
Remove ternary operation : Utilities class percentage,
kbbn2001 May 4, 2017
1f6d03d
Replace deprecated method Utilities.percentageWithTwoCharacters to
gxicxigouxa May 4, 2017
4fdf5fa
Rename Variable / AccountManager's CredentialProvider cp
colrong May 4, 2017
a3c1085
Consolidate Conditional Expression / AccountManager's login /
colrong May 4, 2017
0ee6c46
Introduce Explaining Variable : Utilities class getRealExceptionMessage
kbbn2001 May 4, 2017
6f8b57b
Consolidate Conditional Expression / AccountManager's logOnGoogleAuth /
colrong May 4, 2017
9fa4a0b
Consolidate Conditional Expression / AccountManager's logOnPtc /
colrong May 4, 2017
7677285
make variable class EvolveElement including pokemon and pokemon's
sonyuseon May 4, 2017
92ce978
Consolidate Conditional Expression / AccountController's initialize /
colrong May 4, 2017
8508cc0
Extract Method(successMessage) : result success message in
sonyuseon May 4, 2017
afde5b6
Replace temp with query, Message chain / settings(field; remove),
gxicxigouxa May 4, 2017
45ba598
Replace temp with query / dps1(temp variable; remove), dps2(temp
gxicxigouxa May 4, 2017
82c9d31
Extract Variable / AccountController's logOn /
colrong May 4, 2017
b13a078
Message chain / getPokemonMove1(), getPokemonMove2() / One of the
gxicxigouxa May 4, 2017
5dbc117
Message chain / getPokemonMove1Message(), getPokemonMove2Message() / One
gxicxigouxa May 4, 2017
6a7f531
Extract Variable / AccountController's logOn /
colrong May 4, 2017
710906f
Renaming / initialze -> initialize / Obvious typing error.
gxicxigouxa May 4, 2017
92be9e4
Long method / initialize() / A front of initialize method is to set
gxicxigouxa May 4, 2017
37dde59
Renaming / maxCpCurrent(field), maxCp(field) / Original value names are
gxicxigouxa May 4, 2017
59ff079
Long method, replace temp with query / initialize(),
gxicxigouxa May 4, 2017
845b04c
Extract Method / AccountController's logOn / Dialog box Pop up code
colrong May 4, 2017
187fd17
Consolidate Conditional Expression / AccountController's
colrong May 4, 2017
4dc1947
Consolidate Conditional Expression, Remove Ternary Operation /
colrong May 4, 2017
ad4c6a4
Extract Method / AccountController's deleteLoginData/ more clear
colrong May 4, 2017
e16ec61
Long method, replace temp with query / initialize(),
gxicxigouxa May 4, 2017
1c7b3b9
Extract method / initializeCandiesStatus() / The part
gxicxigouxa May 4, 2017
1d8103b
Replace temp with query / initializeCandiesStatus() / Original local
gxicxigouxa May 4, 2017
2f68d9a
Extract method / getPokeballMessage() / The part of getPokeballMessage()
gxicxigouxa May 4, 2017
1e25687
Message chain / getPokeballMessage() / Method WordUtils.capitalize's
gxicxigouxa May 4, 2017
b59f951
Extract method, long method / InitializePokemonDataAssciateWithTrainer()
gxicxigouxa May 4, 2017
067c5bb
Rename / initializePokemonData() / The part of
gxicxigouxa May 4, 2017
ea3d5bd
Remove unused comments.
gxicxigouxa May 4, 2017
1b1bfa8
Remove all comments.
gxicxigouxa May 4, 2017
d20fbaf
Remove all comments.
gxicxigouxa May 4, 2017
0a7ce60
remove many return phase : Utilities class limit method
kbbn2001 May 5, 2017
f0f0096
rename and Split Temporary Variable : Utilities class
kbbn2001 May 5, 2017
80404f6
remove many return phase : Utilites class concatString method
kbbn2001 May 5, 2017
9446536
Self Encapsulate Field : ConfigNew class json, lastModified field
kbbn2001 May 6, 2017
4831c41
Refactoring error correction / InventoryManager(initialize),
colrong May 7, 2017
d11c6ed
Refactoring error correction / AccountController(getLoginData) / There's
colrong May 7, 2017
381ff22
Extract Method / AccountController's logOn / Google login switch
colrong May 7, 2017
f53eac5
rename : ConfigNew class checkModified method
kbbn2001 May 7, 2017
0b4764e
Merge pull request #6 from gxicxigouxa/develop
kbbn2001 May 7, 2017
b7d9414
1. Extract Variable 2. ivRating 3. To make more readable code
lhh8048 May 7, 2017
605fba8
1. Extract Method 2. moveRating 3. To make more readable code
lhh8048 May 7, 2017
b6c62b7
1. Extract Variable 2. PokemonPerformanceCache 3. To make more readable
lhh8048 May 7, 2017
50772ff
extract method, if get error then return the error message.(in
sonyuseon May 7, 2017
15fbc12
extract method, if don't have enough resources or cases print the
sonyuseon May 7, 2017
064a458
1. Extract Method 2. PokemonPerformanceCache 3. To make more readable
lhh8048 May 7, 2017
a2bb407
1. Extract Method 2. PokemonPerformanceCache 3. To make more readable
lhh8048 May 7, 2017
109c579
extract method, conditional statement, Determine if resources are
sonyuseon May 7, 2017
f2448bd
extract method, if fail to trasfer print error
sonyuseon May 7, 2017
218d559
extract method, if no error, print transfer success
sonyuseon May 7, 2017
05391a4
1. Extract Method 2. getLocalPokeName 3. To make more readable code
lhh8048 May 7, 2017
c33d749
extract method, if evolve success, print message
sonyuseon May 7, 2017
5331920
1. Extract Variable 2. getLocalPokeName 3. To make more readable code
lhh8048 May 7, 2017
f7c26e0
1. Extract Method 2. convertTeamColorToName 3. To make more readable
lhh8048 May 7, 2017
a61ee51
1. Extract Variable 2. hasStab 3. To make more readable code
lhh8048 May 7, 2017
4251036
1. Extract Method 2. PokeNick 3. To make more readable code
lhh8048 May 7, 2017
b0e8b5c
extract method, setting initialize(settingsInitial, in PokemonModel)
sonyuseon May 8, 2017
f4fba5e
fixed the wrong spelling(initiaze->initialize, in PokemonModel)
sonyuseon May 8, 2017
9c297f8
extract method caculation for current pokemonModel(setMaxCPCurrent, in
sonyuseon May 8, 2017
f694ef6
extract method, set Max CP calculation for highest
sonyuseon May 8, 2017
2bdf488
extract data class with many variables (PokemonModelData, in
sonyuseon May 8, 2017
9ada58e
Merge pull request #7 from colrong/develop
kbbn2001 May 8, 2017
cc6bfdb
1. Replace Temp with Query 2. ivRating 3. To make more readable code
lhh8048 May 8, 2017
28271f4
1. Extract Variable 2. ivRating 3. To make more readable code
lhh8048 May 8, 2017
d4484a8
1.Extract Variable 2. ivRating 3. To make more readable code
lhh8048 May 8, 2017
da48dfe
Merge pull request #9 from lhh8048/develop
kbbn2001 May 8, 2017
482333c
Merge branch 'develop' into develop
kbbn2001 May 8, 2017
f6b2f9f
Merge pull request #8 from sonyuseon/develop
kbbn2001 May 8, 2017
a6da0d5
1. Extract Method 2. ivRating 3. To make more readable code
lhh8048 May 8, 2017
2908401
1. Extract Variable 2. weaveDps 3. To make more readable code
lhh8048 May 8, 2017
e85689c
1. Extract Method 2. weaveDps 3. To make more readable code
lhh8048 May 8, 2017
339913e
1. Extract Variable 2. abbreviateType 3. To make more readable code
lhh8048 May 8, 2017
6e260af
1. Extract Method 2. abbreviateType 3. To make more readable code
lhh8048 May 8, 2017
aadabd8
Merge pull request #10 from lhh8048/develop
kbbn2001 May 8, 2017
c7e187f
Extract Method / AccountController's logOn / logOnSavedAccount method
colrong May 8, 2017
6f2910a
Extract Method / AccountController's logOn / logOn Method is too long
colrong May 8, 2017
1e48e95
Merge pull request #11 from colrong/develop
kbbn2001 May 8, 2017
a781930
evolve element data class with setup
sonyuseon May 30, 2017
3fd4616
pokemon model data with setup
sonyuseon May 30, 2017
ff54d4e
setting before applying design pattern
kbbn2001 May 30, 2017
2bbe847
Template method pattern / Manager Package's Initialize
colrong Jun 1, 2017
b2a7de1
rollback (because error)
kbbn2001 Jun 1, 2017
8688a81
apply factory Method pattern
kbbn2001 Jun 1, 2017
8e4aeac
apply Factory Method Pattern and Strategy Pattern
kbbn2001 Jun 1, 2017
7900a36
concrete strategy
sonyuseon Jun 4, 2017
9a7b19f
concrete strategy
sonyuseon Jun 4, 2017
24cf267
concrete strategy
sonyuseon Jun 4, 2017
6bd4d64
concrete strategy
sonyuseon Jun 4, 2017
3336ffb
concrete strategy
Jun 4, 2017
404c7c2
concrete strategy
sonyuseon Jun 4, 2017
d6cbfb4
concrete strategy
sonyuseon Jun 4, 2017
efd7094
concrete strategy
sonyuseon Jun 4, 2017
a24c798
concrete strategy
sonyuseon Jun 4, 2017
e472289
concrete strategy
sonyuseon Jun 4, 2017
10f1000
concrete strategy
sonyuseon Jun 4, 2017
b849e9c
concrete strategy
sonyuseon Jun 4, 2017
e519a6b
concrete strategy
sonyuseon Jun 4, 2017
b4e266e
concrete strategy
sonyuseon Jun 4, 2017
7a3c883
concrete strategy
sonyuseon Jun 4, 2017
2ed297b
concrete strategy
sonyuseon Jun 4, 2017
88f54cb
concrete strategy
sonyuseon Jun 4, 2017
20af9b1
concrete strategy
sonyuseon Jun 4, 2017
77e49d9
concrete strategy
sonyuseon Jun 4, 2017
751b0a0
concrete strategy
sonyuseon Jun 4, 2017
7cc6a8c
concrete strategy
sonyuseon Jun 4, 2017
ffc41af
concrete strategy
sonyuseon Jun 4, 2017
2513f50
concrete strategy
sonyuseon Jun 4, 2017
8e5af71
concrete strategy
sonyuseon Jun 4, 2017
bf64ffc
concrete strategy
sonyuseon Jun 4, 2017
a1705f8
concrete strategy
sonyuseon Jun 4, 2017
58269f1
concrete strategy
sonyuseon Jun 4, 2017
fadc94d
concrete strategy
sonyuseon Jun 4, 2017
ec8f1d2
concrete strategy
sonyuseon Jun 4, 2017
b3966ef
concrete strategy
sonyuseon Jun 4, 2017
4180838
concrete strategy
sonyuseon Jun 4, 2017
5229cfe
concrete strategy
sonyuseon Jun 4, 2017
27256c3
concrete strategy
sonyuseon Jun 4, 2017
7f69124
strategy pattern, context class in
sonyuseon Jun 4, 2017
8070e61
strategy pattern, interface in corriekay.pokegoutil.gui.controller
sonyuseon Jun 4, 2017
1b92e64
A strategy pattern applied to the switch case statement.
sonyuseon Jun 4, 2017
d885c5e
Merge branch 'develop' of https://github.com/sonyuseon/BlossomsPokemo…
Jun 4, 2017
021f5bc
1. Template method pattern
gxicxigouxa Jun 5, 2017
695a344
Merge pull request #12 from sonyuseon/develop
kbbn2001 Jun 5, 2017
f98b378
Merge pull request #13 from gxicxigouxa/develop
kbbn2001 Jun 5, 2017
355475e
Merge pull request #14 from colrong/develop
kbbn2001 Jun 5, 2017
5703c5c
1. Strategy Pattern 2. Browser.java 3. OS에 따라 특정 함수가 다른 작용을 하는데, 각 OS에
lhh8048 Jun 5, 2017
be72330
Merge pull request #15 from lhh8048/develop
kbbn2001 Jun 5, 2017
33bc8e7
managers Package Error correct
colrong Jun 6, 2017
5d4acc1
Merge pull request #16 from colrong/develop
kbbn2001 Jun 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="easymock-3.4.jar"/>

<classpathentry kind="output" path="target/classes"/>
</classpath>
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.metrics.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sourceforge.metrics.nature</nature>
</natures>
</projectDescription>
Binary file added easymock-3.4.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/me/corriekay/pokegoutil/BlossomsPoGoManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void setNewPrimaryStage(final Stage stage) {
public void start(final Stage primaryStage) {
setupGlobalExceptionHandling();

if (ConfigNew.getConfig().getBool(ConfigKey.DEVELOPFLAG)) {
if ((boolean) ConfigNew.getConfig().getAsObject(ConfigKey.DEVELOPFLAG)) {
new ChooseGuiWindowController();
sPrimaryStage.show();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/me/corriekay/pokegoutil/data/enums/PokeColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Object get(final Pokemon p) {

int evolvable = (int) ((double) candies / candiesToEvolve);
int rest = candies % candiesToEvolve;
final boolean transferAfterEvolve = ConfigNew.getConfig().getBool(ConfigKey.TRANSFER_AFTER_EVOLVE);
final boolean transferAfterEvolve = (boolean) ConfigNew.getConfig().getAsObject(ConfigKey.TRANSFER_AFTER_EVOLVE);

// We iterate and get how many candies are added while evolving and if that can make up for some more evolves
int newEvolvable = evolvable;
Expand Down
598 changes: 341 additions & 257 deletions src/me/corriekay/pokegoutil/data/managers/AccountController.java

Large diffs are not rendered by default.

117 changes: 73 additions & 44 deletions src/me/corriekay/pokegoutil/data/managers/AccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,51 @@ private void deleteLoginData(final LoginType type) {
*/
private void deleteLoginData(final LoginType type, final boolean deleteSaveAuth) {
if (deleteSaveAuth) {
config.delete(ConfigKey.LOGIN_SAVE_AUTH);
deleteSavedLoginData();
}

switch (type) {
case ALL:
config.delete(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN);
config.delete(ConfigKey.LOGIN_GOOGLE_APP_USERNAME);
config.delete(ConfigKey.LOGIN_GOOGLE_APP_PASSWORD);
config.delete(ConfigKey.LOGIN_PTC_USERNAME);
config.delete(ConfigKey.LOGIN_PTC_PASSWORD);
deleteGoogleAuthLoginData();
deleteGoogleAppLoginData();
deletePtcLoginData();
break;
case GOOGLE_AUTH:
config.delete(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN);
deleteGoogleAuthLoginData();
break;
case GOOGLE_APP_PASSWORD:
config.delete(ConfigKey.LOGIN_GOOGLE_APP_USERNAME);
config.delete(ConfigKey.LOGIN_GOOGLE_APP_PASSWORD);
deleteGoogleAppLoginData();
break;
case PTC:
config.delete(ConfigKey.LOGIN_PTC_USERNAME);
config.delete(ConfigKey.LOGIN_PTC_PASSWORD);
deletePtcLoginData();
break;
default:
}
}

private void deleteGoogleAuthLoginData() {
config.delete(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN);
}

private void deleteSavedLoginData() {
config.delete(ConfigKey.LOGIN_SAVE_AUTH);
}

private void deletePtcLoginData() {
config.delete(ConfigKey.LOGIN_PTC_USERNAME);
config.delete(ConfigKey.LOGIN_PTC_PASSWORD);
}

private void deleteGoogleAppLoginData() {
config.delete(ConfigKey.LOGIN_GOOGLE_APP_USERNAME);
config.delete(ConfigKey.LOGIN_GOOGLE_APP_PASSWORD);
}

public LoginData getLoginData() {
final LoginData loginData = new LoginData(
config.getString(ConfigKey.LOGIN_PTC_USERNAME),
config.getString(ConfigKey.LOGIN_PTC_PASSWORD),
config.getString(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN));
(String) config.getAsObject(ConfigKey.LOGIN_PTC_USERNAME),
(String) config.getAsObject(ConfigKey.LOGIN_PTC_PASSWORD),
(String) config.getAsObject(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN));

if (loginData.isValidGoogleLogin()) {
loginData.setSavedToken(true);
Expand All @@ -110,7 +124,11 @@ public PlayerAccount getPlayerAccount() {
}

public PlayerProfile getPlayerProfile() {
return go != null ? go.getPlayerProfile() : null;
PlayerProfile result = null;
if(go != null)
result = go.getPlayerProfile();

return result;
}

private void initOtherControllers() {
Expand All @@ -126,20 +144,21 @@ private void initOtherControllers() {
* @return results of the login
*/
public BpmResult login(final LoginData loginData) {
BpmResult result = new BpmResult("Invalid Login Type");
switch (loginData.getLoginType()) {
case GOOGLE_AUTH:
if (loginData.isValidGoogleLogin()) {
return logOnGoogleAuth(loginData);
result = logOnGoogleAuth(loginData);
}
break;
case PTC:
if (loginData.isValidPtcLogin()) {
return logOnPtc(loginData);
result = logOnPtc(loginData);
}
break;
default:
}
return new BpmResult("Invalid Login Type");
return result;
}

/**
Expand All @@ -150,12 +169,14 @@ public BpmResult login(final LoginData loginData) {
*/
private BpmResult logOnGoogleAuth(final LoginData loginData) {
OkHttpClient http;
CredentialProvider cp;
CredentialProvider credentialProvider = null;
http = new OkHttpClient();

final String authCode = loginData.getToken();
final boolean saveAuth = config.getBool(ConfigKey.LOGIN_SAVE_AUTH);
final boolean saveAuth = (boolean) config.getAsObject(ConfigKey.LOGIN_SAVE_AUTH);

BpmResult result = new BpmResult();

boolean shouldRefresh = false;
if (loginData.isSavedToken() && saveAuth) {
shouldRefresh = true;
Expand All @@ -174,24 +195,27 @@ private BpmResult logOnGoogleAuth(final LoginData loginData) {
throw new LoginFailedException();
}

cp = provider;
credentialProvider = provider;
if (saveAuth && !shouldRefresh) {
config.setString(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN, provider.getRefreshToken());
config.setFromObject(ConfigKey.LOGIN_GOOGLE_AUTH_TOKEN, provider.getRefreshToken());
} else if (!saveAuth) {
deleteLoginData(LoginType.GOOGLE_AUTH);
}
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException e) {
deleteLoginData(LoginType.GOOGLE_APP_PASSWORD);
return new BpmResult(e.getMessage());
result = new BpmResult(e.getMessage());
}

try {
prepareLogin(cp, http);
return new BpmResult();
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException | HashException e) {
deleteLoginData(LoginType.ALL);
return new BpmResult(e.getMessage());

if (result.isSuccess()) {
try {
prepareLogin(credentialProvider, http);
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException | HashException e) {
deleteLoginData(LoginType.ALL);
result = new BpmResult(e.getMessage());
}
}

return result;
}

/**
Expand All @@ -202,33 +226,38 @@ private BpmResult logOnGoogleAuth(final LoginData loginData) {
*/
private BpmResult logOnPtc(final LoginData loginData) {
OkHttpClient http;
CredentialProvider cp;
CredentialProvider credentialProvider = null;
http = new OkHttpClient();

final String username = loginData.getUsername();
final String password = loginData.getPassword();
final boolean saveAuth = config.getBool(ConfigKey.LOGIN_SAVE_AUTH);
final boolean saveAuth = (boolean) config.getAsObject(ConfigKey.LOGIN_SAVE_AUTH);

BpmResult result = new BpmResult();

try {
cp = new PtcCredentialProvider(http, username, password);
config.setString(ConfigKey.LOGIN_PTC_USERNAME, username);
credentialProvider = new PtcCredentialProvider(http, username, password);
config.setFromObject(ConfigKey.LOGIN_PTC_USERNAME, username);
if (saveAuth) {
config.setString(ConfigKey.LOGIN_PTC_PASSWORD, password);
config.setFromObject(ConfigKey.LOGIN_PTC_PASSWORD, password);
} else {
deleteLoginData(LoginType.PTC);
}
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException e) {
deleteLoginData(LoginType.PTC);
return new BpmResult(e.getMessage());
result = new BpmResult(e.getMessage());
}

try {
prepareLogin(cp, http);
return new BpmResult();
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException | HashException e) {
deleteLoginData(LoginType.ALL);
return new BpmResult(e.getMessage());

if (result.isSuccess()) {
try {
prepareLogin(credentialProvider, http);
} catch (LoginFailedException | RemoteServerException | CaptchaActiveException | HashException e) {
deleteLoginData(LoginType.ALL);
result = new BpmResult(e.getMessage());
}
}

return result;
}

/**
Expand Down Expand Up @@ -256,6 +285,6 @@ private void prepareLogin(final CredentialProvider cp, final OkHttpClient http)
* @param shouldSave settings for saveAuth
*/
public void setSaveLogin(final boolean shouldSave) {
config.setBool(ConfigKey.LOGIN_SAVE_AUTH, shouldSave);
config.setFromObject(ConfigKey.LOGIN_SAVE_AUTH, shouldSave);
}
}
17 changes: 7 additions & 10 deletions src/me/corriekay/pokegoutil/data/managers/InventoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ private InventoryManager() {
}

public static void initialize(PokemonGo go) {
if (sIsInit)
return;

try {
S_INSTANCE.inventories = go.getInventories();
} catch (Exception e) {
//TODO sumthin here
return;
if (!sIsInit) {
try {
S_INSTANCE.inventories = go.getInventories();
sIsInit = true;
} catch (Exception e) {
// TODO sumthin here
}
}

sIsInit = true;
}

public static Inventories getInventories() throws LoginFailedException, RemoteServerException {
Expand Down
23 changes: 11 additions & 12 deletions src/me/corriekay/pokegoutil/data/managers/PokemonBagManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import me.corriekay.pokegoutil.data.models.PokemonModel;

/*
* This controller takes care of handling pokémon
* This controller takes care of handling pok챕mon
*/
public class PokemonBagManager {

Expand All @@ -19,23 +19,22 @@ private PokemonBagManager() {
}

public static void initialize(PokemonGo go) {
if (sIsInit)
return;
try {
S_INSTANCE.pokemonBag = new PokemonBag(go.getInventories().getPokebank().getPokemons());
} catch (Exception e) {
//TODO sumthin here
return;
if (!sIsInit) {
try {
S_INSTANCE.pokemonBag = new PokemonBag(go.getInventories().getPokebank().getPokemons());
sIsInit = true;
} catch (Exception e) {
// TODO sumthin here
}
}

sIsInit = true;

}

public static ObservableList<PokemonModel>getAllPokemon(){
public static ObservableList<PokemonModel> getAllPokemon() {
return sIsInit ? S_INSTANCE.pokemonBag.getAllPokemon() : null;
}

public static int getNbPokemon(){
public static int getNbPokemon() {
return sIsInit ? S_INSTANCE.pokemonBag.getNumberPokemon() : 0;
}
}
8 changes: 3 additions & 5 deletions src/me/corriekay/pokegoutil/data/managers/ProfileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ private ProfileManager() {
}

public static void initialize(PokemonGo go) {
if (sIsInit)
return;

S_INSTANCE.pp = go.getPlayerProfile();

if (!sIsInit)
S_INSTANCE.pp = go.getPlayerProfile();

sIsInit = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/me/corriekay/pokegoutil/data/models/LoginData.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void setUsername(String username) {

@Override
public String toString() {
return String.format("Username: %s | Password: %s | Token: %s | LoginType: %s | isSavedToken %b",
return String.format("Username: %s | Password: %s | Token: %s | LoginType: %s | isSavedToken: %b",
username, password, token, loginType, isSavedToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.corriekay.pokegoutil.data.models;

import com.pokegoapi.api.pokemon.Pokemon;
import com.pokegoapi.exceptions.NoSuchItemException;

import POGOProtos.Enums.PokemonIdOuterClass.PokemonId;

public class PokemonCpCurrentProvider extends PokemonCpProvider {

public PokemonCpCurrentProvider(Pokemon pokemon) {
super(pokemon);
}

@Override
protected int getMaxCpValue(Pokemon pokemon) throws NoSuchItemException {
return pokemon.getMaxCpForPlayer();
}

@Override
protected int getMaxEvolvedCpValue(Pokemon pokemon, PokemonId pokemonId) {
return pokemon.getMaxCpFullEvolveAndPowerupForPlayer(pokemonId);
}

}
Loading