mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
added code-logic for listening websocket-double
This commit is contained in:
@@ -23,13 +23,18 @@ export function ConnectToChat() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const dataObject = JSON.parse(event.data);
|
const dataObject = JSON.parse(event.data);
|
||||||
console.log(dataObject)
|
|
||||||
|
|
||||||
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
||||||
eventBus.emit('dataChat', event.data);
|
eventBus.emit('dataChat', event.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataObject.MessageType == 'DoubleGameState') {
|
||||||
|
eventBus.emit('doubleGame', event.data)
|
||||||
|
console.log('data')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (dataObject.MessageType == "CrashGameState") {
|
if (dataObject.MessageType == "CrashGameState") {
|
||||||
eventBus.emit('crash', event.data);
|
eventBus.emit('crash', event.data);
|
||||||
return;
|
return;
|
||||||
@@ -41,12 +46,6 @@ export function ConnectToChat() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataObject.MessageType == 'DoubleGameState') {
|
|
||||||
eventBus.emit('doubleGame', event.data)
|
|
||||||
console.log('data')
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
void(error);
|
void(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,44 +65,58 @@ export default {
|
|||||||
const slides = reactive([
|
const slides = reactive([
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
||||||
target: "BlackDouble",
|
target: "Black",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
||||||
target: "BlackDouble",
|
target: "Red",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleGreenDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleGreenDouble.png"),
|
||||||
target: "GreenDouble",
|
target: "Green",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleRedDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleRedDouble.png"),
|
||||||
target: "RedDouble",
|
target: "Red",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
||||||
target: "BlackDouble",
|
target: "Black",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
|
||||||
target: "BlackDouble",
|
target: "Red",
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
let autoPlay = ref(500)
|
let autoPlay = ref(0)
|
||||||
|
let targetColor = ref('')
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
eventBus.on('doubleGame', (dataDouble) => {
|
eventBus.on('doubleGame', (dataDouble) => {
|
||||||
console.log(dataDouble)
|
console.log('data mounted')
|
||||||
|
const dataDoubleParse = JSON.parse(dataDouble)
|
||||||
|
console.log(dataDoubleParse)
|
||||||
|
|
||||||
|
if (dataDoubleParse.Status === 'InGame') {
|
||||||
|
autoPlay.value = 500
|
||||||
|
targetColor.value = dataDoubleParse.WInColor
|
||||||
|
console.log('213')
|
||||||
|
}
|
||||||
|
// else if (dataDoubleParse.Status === 'GameEnd') {
|
||||||
|
// targetColor.value = dataDoubleParse.WInColor
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
console.log('mount')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleStepCarousel(data) {
|
function handleStepCarousel(data) {
|
||||||
try {
|
try {
|
||||||
let { currentSlideIndex } = data
|
if (targetColor.value !== '') {
|
||||||
|
let { currentSlideIndex } = data
|
||||||
|
console.log(slides[currentSlideIndex].target == targetColor.value)
|
||||||
|
|
||||||
if (slides[currentSlideIndex + 1].target == 'RedDouble') {
|
if (slides[currentSlideIndex + 1].target == targetColor.value) {
|
||||||
stopAutoPlay()
|
stopAutoPlay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -114,7 +128,7 @@ export default {
|
|||||||
autoPlay.value = 0
|
autoPlay.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return { slides, autoPlay, handleStepCarousel, stopAutoPlay }
|
return { slides, autoPlay, handleStepCarousel, stopAutoPlay, targetColor }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user