Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EmidWife-New
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-24-005
EmidWife-New
Commits
cc8603af
Commit
cc8603af
authored
May 17, 2024
by
Malsha Jayakody
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix message errors
parent
5229c7c7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
40 deletions
+30
-40
src/screens/home/game/game02/level01.js
src/screens/home/game/game02/level01.js
+10
-15
src/screens/home/game/game02/level02.js
src/screens/home/game/game02/level02.js
+20
-25
No files found.
src/screens/home/game/game02/level01.js
View file @
cc8603af
...
@@ -159,42 +159,37 @@ const Game02Level01 = ({navigation, route}) => {
...
@@ -159,42 +159,37 @@ const Game02Level01 = ({navigation, route}) => {
// Use a setTimeout to ensure state updates have been applied before check
// Use a setTimeout to ensure state updates have been applied before check
setTimeout
(()
=>
{
setTimeout
(()
=>
{
if
(
unhealthyCost
>
2000
)
{
if
(
unhealthyCost
+
item
.
cost
>
2000
)
{
// ensure the current cost is added to total for the check
Alert
.
alert
(
'
Game lost!
'
,
'
Choose healthier foods. 🍇🍌🍉🥬🥕🍒
'
,
Alert
.
alert
(
'
Game lost!
'
,
'
Choose healthier foods. 🍇🍌🍉🥬🥕🍒
'
,
[
[
{
{
text
:
'
OK
'
,
text
:
'
OK
'
,
onPress
:
()
=>
{
onPress
:
()
=>
navigation
.
navigate
(
ROUTES
.
GAME_QUIZ_OPTIONS
),
navigation
.
navigate
(
ROUTES
.
GAME_QUIZ_OPTIONS
);
},
},
},
]);
]);
}
else
if
(
healthyCost
>
2000
)
{
}
else
if
(
healthyCost
+
item
.
cost
>
2000
)
{
// ensure the current cost is added to total for the check
Alert
.
alert
(
'
Game won!
'
,
Alert
.
alert
(
'
Game won!
'
,
'
Congratulations! You have made healthy choices.
'
,
[
[
{
{
text
:
'
OK
'
,
text
:
'
OK
'
,
onPress
:
()
=>
{
onPress
:
()
=>
navigation
.
navigate
(
ROUTES
.
Game02ProgressLevel03
),
navigation
.
navigate
(
ROUTES
.
Game02ProgressLevel03
);
},
},
},
]);
]);
backgroundMusic
.
current
.
setVolume
(
0.0
);
backgroundMusic
.
current
.
setVolume
(
0.0
);
}
}
},
0
);
},
0
);
}
else
{
}
else
{
Alert
.
alert
(
'
Not enough budget
'
,
Alert
.
alert
(
'
Not enough budget
'
,
'
Please try to manage your budget better.
'
,
[
[
{
{
text
:
'
OK
'
,
text
:
'
OK
'
,
onPress
:
()
=>
{
onPress
:
()
=>
navigation
.
navigate
(
ROUTES
.
CHOOSE_GAME
),
navigation
.
navigate
(
ROUTES
.
CHOOSE_GAME
);
},
},
},
]);
]);
}
}
};
};
return
(
return
(
<
ScrollView
style
=
{
styles
.
container
}
>
<
ScrollView
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
rack
}
>
<
View
style
=
{
styles
.
rack
}
>
...
...
src/screens/home/game/game02/level02.js
View file @
cc8603af
...
@@ -81,44 +81,39 @@ const CravingsPuzzleGame02Level02 = ({navigation}) => {
...
@@ -81,44 +81,39 @@ const CravingsPuzzleGame02Level02 = ({navigation}) => {
};
};
const
purchaseItem
=
item
=>
{
const
purchaseItem
=
item
=>
{
// Check if the budget allows for the purchase
if
(
budget
-
item
.
cost
>=
0
)
{
if
(
budget
-
item
.
cost
>=
0
)
{
// Update the budget and purchased items
setBudget
(
budget
-
item
.
cost
);
setBudget
(
budget
-
item
.
cost
);
setPurchasedItems
([...
purchasedItems
,
item
]);
setPurchasedItems
([...
purchasedItems
,
item
]);
// Update the cost tracking based on whether the item is essential
if
(
item
.
essential
===
true
)
{
if
(
item
.
essential
===
true
)
{
setHealthyCost
(
prevCost
=>
prevCost
+
item
.
cost
);
setHealthyCost
(
prevCost
=>
prevCost
+
item
.
cost
);
}
else
{
}
else
{
setUnhealthyCost
(
prevCost
=>
prevCost
+
item
.
cost
);
setUnhealthyCost
(
prevCost
=>
prevCost
+
item
.
cost
);
}
}
setTimeout
(()
=>
{
// Delay is unnecessary, so directly execute the checks
if
(
unhealthyC
ost
>
2000
)
{
if
(
unhealthyCost
+
item
.
c
ost
>
2000
)
{
Alert
.
alert
(
'
Game lost!
'
,
'
Choose essi
ntial items!
'
,
[
Alert
.
alert
(
'
Game lost!
'
,
'
Choose esse
ntial items!
'
,
[
{
{
text
:
'
OK
'
,
text
:
'
OK
'
,
onPress
:
()
=>
{
onPress
:
()
=>
navigation
.
navigate
(
ROUTES
.
GAME_QUIZ_OPTIONS
),
navigation
.
navigate
(
ROUTES
.
GAME_QUIZ_OPTIONS
);
},
},
},
]);
]);
}
else
if
(
healthyC
ost
>
2000
)
{
}
else
if
(
healthyCost
+
item
.
c
ost
>
2000
)
{
Alert
.
alert
(
'
Game won
!
'
,
[
Alert
.
alert
(
'
Game won!
'
,
'
Congratulations
!
'
,
[
{
{
text
:
'
OK
'
,
text
:
'
OK
'
,
onPress
:
()
=>
{
onPress
:
()
=>
navigation
.
navigate
(
ROUTES
.
Game02ProgressLevel06
),
navigation
.
navigate
(
ROUTES
.
Game02ProgressLevel06
);
},
},
},
]);
]);
backgroundMusic
.
current
.
setVolume
(
0.0
);
backgroundMusic
.
current
.
setVolume
(
0.0
);
}
}
},
0
);
}
else
{
}
else
{
Alert
.
alert
(
'
Not enough budget
'
);
Alert
.
alert
(
'
Not enough budget
'
);
}
}
setBudget
(
currentBudget
=>
currentBudget
-
item
.
cost
);
setPurchasedItems
(
currentItems
=>
[...
currentItems
,
item
]);
};
};
return
(
return
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment